1
1
"""Test core util functions."""
2
2
3
3
import os
4
- import mock
5
4
6
- from mock import call
5
+ import mock
7
6
from django .http import Http404
8
7
from django .test import TestCase
9
8
from django_dynamic_fixture import get
9
+ from mock import call
10
10
11
+ from readthedocs .builds .constants import LATEST
11
12
from readthedocs .builds .models import Version
12
- from readthedocs .core .utils .general import wipe_version_via_slugs
13
- from readthedocs .projects .tasks import remove_dirs
14
13
from readthedocs .core .utils import slugify , trigger_build
14
+ from readthedocs .core .utils .general import wipe_version_via_slugs
15
15
from readthedocs .projects .models import Project
16
- from readthedocs .builds . constants import LATEST
16
+ from readthedocs .projects . tasks import remove_dirs
17
17
18
18
19
19
class CoreUtilTests (TestCase ):
@@ -54,15 +54,13 @@ def test_trigger_build_when_version_not_provided_default_version_exist(self, upd
54
54
'build_pk' : mock .ANY ,
55
55
}
56
56
57
- update_docs_task .signature .assert_has_calls ([
58
- mock .call (
59
- args = (version_1 .pk ,),
60
- kwargs = kwargs ,
61
- options = mock .ANY ,
62
- immutable = True ,
63
- ),
64
- ])
65
-
57
+ update_docs_task .signature .assert_called_with (
58
+ args = (version_1 .pk ,),
59
+ kwargs = kwargs ,
60
+ options = mock .ANY ,
61
+ immutable = True ,
62
+ )
63
+
66
64
@mock .patch ('readthedocs.projects.tasks.update_docs_task' )
67
65
def test_trigger_build_when_version_not_provided_default_version_doesnt_exist (self , update_docs_task ):
68
66
@@ -78,14 +76,12 @@ def test_trigger_build_when_version_not_provided_default_version_doesnt_exist(se
78
76
'build_pk' : mock .ANY ,
79
77
}
80
78
81
- update_docs_task .signature .assert_has_calls ([
82
- mock .call (
83
- args = (version .pk ,),
84
- kwargs = kwargs ,
85
- options = mock .ANY ,
86
- immutable = True ,
87
- ),
88
- ])
79
+ update_docs_task .signature .assert_called_with (
80
+ args = (version .pk ,),
81
+ kwargs = kwargs ,
82
+ options = mock .ANY ,
83
+ immutable = True ,
84
+ )
89
85
90
86
@mock .patch ('readthedocs.projects.tasks.update_docs_task' )
91
87
def test_trigger_custom_queue (self , update_docs ):
@@ -102,15 +98,12 @@ def test_trigger_custom_queue(self, update_docs):
102
98
'time_limit' : 720 ,
103
99
'soft_time_limit' : 600 ,
104
100
}
105
- update_docs .signature .assert_has_calls ([
106
- mock .call (
107
- args = (self .version .pk ,),
108
- kwargs = kwargs ,
109
- options = options ,
110
- immutable = True ,
111
- ),
112
- ])
113
- update_docs .signature ().apply_async .assert_called ()
101
+ update_docs .signature .assert_called_with (
102
+ args = (self .version .pk ,),
103
+ kwargs = kwargs ,
104
+ options = options ,
105
+ immutable = True ,
106
+ )
114
107
115
108
@mock .patch ('readthedocs.projects.tasks.update_docs_task' )
116
109
def test_trigger_build_time_limit (self , update_docs ):
@@ -126,15 +119,12 @@ def test_trigger_build_time_limit(self, update_docs):
126
119
'time_limit' : 720 ,
127
120
'soft_time_limit' : 600 ,
128
121
}
129
- update_docs .signature .assert_has_calls ([
130
- mock .call (
131
- args = (self .version .pk ,),
132
- kwargs = kwargs ,
133
- options = options ,
134
- immutable = True ,
135
- ),
136
- ])
137
- update_docs .signature ().apply_async .assert_called ()
122
+ update_docs .signature .assert_called_with (
123
+ args = (self .version .pk ,),
124
+ kwargs = kwargs ,
125
+ options = options ,
126
+ immutable = True ,
127
+ )
138
128
139
129
@mock .patch ('readthedocs.projects.tasks.update_docs_task' )
140
130
def test_trigger_build_invalid_time_limit (self , update_docs ):
@@ -151,15 +141,12 @@ def test_trigger_build_invalid_time_limit(self, update_docs):
151
141
'time_limit' : 720 ,
152
142
'soft_time_limit' : 600 ,
153
143
}
154
- update_docs .signature .assert_has_calls ([
155
- mock .call (
156
- args = (self .version .pk ,),
157
- kwargs = kwargs ,
158
- options = options ,
159
- immutable = True ,
160
- ),
161
- ])
162
- update_docs .signature ().apply_async .assert_called ()
144
+ update_docs .signature .assert_called_with (
145
+ args = (self .version .pk ,),
146
+ kwargs = kwargs ,
147
+ options = options ,
148
+ immutable = True ,
149
+ )
163
150
164
151
@mock .patch ('readthedocs.projects.tasks.update_docs_task' )
165
152
def test_trigger_build_rounded_time_limit (self , update_docs ):
@@ -176,15 +163,12 @@ def test_trigger_build_rounded_time_limit(self, update_docs):
176
163
'time_limit' : 3 ,
177
164
'soft_time_limit' : 3 ,
178
165
}
179
- update_docs .signature .assert_has_calls ([
180
- mock .call (
181
- args = (self .version .pk ,),
182
- kwargs = kwargs ,
183
- options = options ,
184
- immutable = True ,
185
- ),
186
- ])
187
- update_docs .signature ().apply_async .assert_called ()
166
+ update_docs .signature .assert_called_with (
167
+ args = (self .version .pk ,),
168
+ kwargs = kwargs ,
169
+ options = options ,
170
+ immutable = True ,
171
+ )
188
172
189
173
def test_slugify (self ):
190
174
"""Test additional slugify."""
0 commit comments