Skip to content

Commit

Permalink
Fix mock calls in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed May 1, 2018
1 parent 46a4f71 commit c87e81e
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions readthedocs/rtd_tests/tests/test_core_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from django_dynamic_fixture import get
from django.test import TestCase
from django.test.utils import override_settings

from readthedocs.projects.models import Project
from readthedocs.builds.models import Version
Expand All @@ -22,60 +21,58 @@ def setUp(self):
def test_trigger_build_time_limit(self, update_docs):
"""Pass of time limit"""
trigger_build(project=self.project, version=self.version)
update_docs().apply_async.assert_has_calls([
update_docs().si.assert_has_calls([
mock.call(
self.project.pk,
time_limit=720,
soft_time_limit=600,
queue=mock.ANY,
kwargs={
'pk': self.project.id,
'force': False,
'record': True,
'build_pk': mock.ANY,
'version_pk': self.version.id
}
)
force=False,
record=True,
build_pk=mock.ANY,
version_pk=self.version.id,
),
])
update_docs().si().apply_async.assert_called()

@mock.patch('readthedocs.projects.tasks.UpdateDocsTask')
def test_trigger_build_invalid_time_limit(self, update_docs):
"""Time limit as string"""
self.project.container_time_limit = '200s'
trigger_build(project=self.project, version=self.version)
update_docs().apply_async.assert_has_calls([
update_docs().si.assert_has_calls([
mock.call(
self.project.pk,
time_limit=720,
soft_time_limit=600,
queue=mock.ANY,
kwargs={
'pk': self.project.id,
'force': False,
'record': True,
'build_pk': mock.ANY,
'version_pk': self.version.id
}
)
force=False,
record=True,
build_pk=mock.ANY,
version_pk=self.version.id,
),
])
update_docs().si().apply_async.assert_called()

@mock.patch('readthedocs.projects.tasks.UpdateDocsTask')
def test_trigger_build_rounded_time_limit(self, update_docs):
"""Time limit should round down"""
self.project.container_time_limit = 3
trigger_build(project=self.project, version=self.version)
update_docs().apply_async.assert_has_calls([
update_docs().si.assert_has_calls([
mock.call(
time_limit=3,
soft_time_limit=3,
self.project.pk,
time_limit=720,
soft_time_limit=600,
queue=mock.ANY,
kwargs={
'pk': self.project.id,
'force': False,
'record': True,
'build_pk': mock.ANY,
'version_pk': self.version.id
}
)
force=False,
record=True,
build_pk=mock.ANY,
version_pk=self.version.id,
),
])
update_docs().si().apply_async.assert_called()


def test_slugify(self):
"""Test additional slugify"""
Expand Down

0 comments on commit c87e81e

Please sign in to comment.