2
2
import subprocess
3
3
4
4
from django .test import TestCase
5
+ from django_dynamic_fixture import get
6
+ from django_dynamic_fixture import fixture
5
7
import mock
6
8
9
+ from readthedocs .projects .models import Project
7
10
from readthedocs .projects .tasks import build_docs
8
- from readthedocs .rtd_tests .factories .projects_factories import ProjectFactory
9
11
from readthedocs .rtd_tests .mocks .paths import fake_paths_lookup
10
12
from readthedocs .doc_builder .loader import get_builder_class
11
13
@@ -46,7 +48,11 @@ def test_build(self, mock_Popen, mock_api_versions, mock_chdir, mock_apiv2_downl
46
48
mock_Popen .return_value = mock_process
47
49
mock_Popen .side_effect = build_subprocess_side_effect
48
50
49
- project = ProjectFactory (allow_comments = True )
51
+ project = get (Project ,
52
+ slug = 'project-1' ,
53
+ documentation_type = 'sphinx' ,
54
+ conf_py_file = 'test_conf.py' ,
55
+ versions = [fixture ()])
50
56
51
57
version = project .versions .all ()[0 ]
52
58
mock_api_versions .return_value = [version ]
@@ -77,7 +83,10 @@ def test_build(self, mock_Popen, mock_api_versions, mock_chdir, mock_apiv2_downl
77
83
def test_builder_comments (self ):
78
84
79
85
# Normal build
80
- project = ProjectFactory (allow_comments = True )
86
+ project = get (Project ,
87
+ documentation_type = 'sphinx' ,
88
+ allow_comments = True ,
89
+ versions = [fixture ()])
81
90
version = project .versions .all ()[0 ]
82
91
builder_class = get_builder_class (project .documentation_type )
83
92
builder = builder_class (version )
@@ -86,7 +95,10 @@ def test_builder_comments(self):
86
95
def test_builder_no_comments (self ):
87
96
88
97
# Normal build
89
- project = ProjectFactory (allow_comments = False )
98
+ project = get (Project ,
99
+ documentation_type = 'sphinx' ,
100
+ allow_comments = False ,
101
+ versions = [fixture ()])
90
102
version = project .versions .all ()[0 ]
91
103
builder_class = get_builder_class (project .documentation_type )
92
104
builder = builder_class (version )
@@ -114,9 +126,13 @@ def test_build_respects_pdf_flag(self,
114
126
mock_Popen .return_value = mock_process
115
127
mock_Popen .side_effect = build_subprocess_side_effect
116
128
117
- project = ProjectFactory (
118
- enable_pdf_build = True ,
119
- enable_epub_build = False )
129
+ project = get (Project ,
130
+ slug = 'project-1' ,
131
+ documentation_type = 'sphinx' ,
132
+ conf_py_file = 'test_conf.py' ,
133
+ enable_pdf_build = True ,
134
+ enable_epub_build = False ,
135
+ versions = [fixture ()])
120
136
version = project .versions .all ()[0 ]
121
137
122
138
conf_path = os .path .join (project .checkout_path (version .slug ), project .conf_py_file )
@@ -158,9 +174,13 @@ def test_build_respects_epub_flag(self,
158
174
mock_Popen .return_value = mock_process
159
175
mock_Popen .side_effect = build_subprocess_side_effect
160
176
161
- project = ProjectFactory (
162
- enable_pdf_build = False ,
163
- enable_epub_build = True )
177
+ project = get (Project ,
178
+ slug = 'project-2' ,
179
+ documentation_type = 'sphinx' ,
180
+ conf_py_file = 'test_conf.py' ,
181
+ enable_pdf_build = False ,
182
+ enable_epub_build = True ,
183
+ versions = [fixture ()])
164
184
version = project .versions .all ()[0 ]
165
185
166
186
conf_path = os .path .join (project .checkout_path (version .slug ), project .conf_py_file )
0 commit comments