14
14
from readthedocs .projects .tasks import remove_dirs
15
15
from readthedocs .core .utils import slugify , trigger_build
16
16
from readthedocs .projects .models import Project
17
+ from readthedocs .builds .constants import LATEST
17
18
18
19
19
20
class CoreUtilTests (TestCase ):
@@ -33,6 +34,34 @@ def test_trigger_skipped_project(self, update_docs_task):
33
34
self .assertEqual (result , (None , None ))
34
35
self .assertFalse (update_docs_task .signature .called )
35
36
self .assertFalse (update_docs_task .signature ().apply_async .called )
37
+
38
+ @mock .patch ('readthedocs.projects.tasks.update_docs_task' )
39
+ def test_trigger_build_when_latest_is_not_activated (self , update_docs_task ):
40
+ self .assertFalse (Version .objects .filter (slug = 'test-slug' ).exists ())
41
+
42
+ project_1 = get (Project )
43
+ version_1 = get (Version , project = project_1 , slug = 'test-slug' )
44
+ active_version = project_1 .versions .filter (slug = LATEST ).update (active = False )
45
+
46
+ project_1 .default_branch = 'test-slug'
47
+ project_1 .save ()
48
+
49
+ trigger_build (project = project_1 )
50
+ kwargs = {
51
+ 'version_pk' : version_1 .pk ,
52
+ 'record' : True ,
53
+ 'force' : False ,
54
+ 'build_pk' : mock .ANY ,
55
+ }
56
+
57
+ update_docs_task .signature .assert_has_calls ([
58
+ mock .call (
59
+ args = (project_1 .pk ,),
60
+ kwargs = kwargs ,
61
+ options = mock .ANY ,
62
+ immutable = True ,
63
+ ),
64
+ ])
36
65
37
66
@mock .patch ('readthedocs.projects.tasks.update_docs_task' )
38
67
def test_trigger_custom_queue (self , update_docs ):
0 commit comments