Skip to content

Commit 45edfc9

Browse files
Refactor test_builds to use explicit dynamic fixtures instead of factories
1 parent 01986a6 commit 45edfc9

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

readthedocs/rtd_tests/tests/test_builds.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
import subprocess
33

44
from django.test import TestCase
5+
from django_dynamic_fixture import get
6+
from django_dynamic_fixture import fixture
57
import mock
68

9+
from readthedocs.projects.models import Project
710
from readthedocs.projects.tasks import build_docs
8-
from readthedocs.rtd_tests.factories.projects_factories import ProjectFactory
911
from readthedocs.rtd_tests.mocks.paths import fake_paths_lookup
1012
from readthedocs.doc_builder.loader import get_builder_class
1113

@@ -46,7 +48,11 @@ def test_build(self, mock_Popen, mock_api_versions, mock_chdir, mock_apiv2_downl
4648
mock_Popen.return_value = mock_process
4749
mock_Popen.side_effect = build_subprocess_side_effect
4850

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()])
5056

5157
version = project.versions.all()[0]
5258
mock_api_versions.return_value = [version]
@@ -77,7 +83,10 @@ def test_build(self, mock_Popen, mock_api_versions, mock_chdir, mock_apiv2_downl
7783
def test_builder_comments(self):
7884

7985
# Normal build
80-
project = ProjectFactory(allow_comments=True)
86+
project = get(Project,
87+
documentation_type='sphinx',
88+
allow_comments=True,
89+
versions=[fixture()])
8190
version = project.versions.all()[0]
8291
builder_class = get_builder_class(project.documentation_type)
8392
builder = builder_class(version)
@@ -86,7 +95,10 @@ def test_builder_comments(self):
8695
def test_builder_no_comments(self):
8796

8897
# Normal build
89-
project = ProjectFactory(allow_comments=False)
98+
project = get(Project,
99+
documentation_type='sphinx',
100+
allow_comments=False,
101+
versions=[fixture()])
90102
version = project.versions.all()[0]
91103
builder_class = get_builder_class(project.documentation_type)
92104
builder = builder_class(version)
@@ -114,9 +126,13 @@ def test_build_respects_pdf_flag(self,
114126
mock_Popen.return_value = mock_process
115127
mock_Popen.side_effect = build_subprocess_side_effect
116128

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()])
120136
version = project.versions.all()[0]
121137

122138
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,
158174
mock_Popen.return_value = mock_process
159175
mock_Popen.side_effect = build_subprocess_side_effect
160176

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()])
164184
version = project.versions.all()[0]
165185

166186
conf_path = os.path.join(project.checkout_path(version.slug), project.conf_py_file)

0 commit comments

Comments
 (0)