@@ -30,23 +30,13 @@ def setUp(self):
30
30
self .project = Project .objects .get (slug = 'pip' )
31
31
self .version = self .project .versions .first ()
32
32
33
- build_env = namedtuple ('project' , 'version' )
34
- build_env .project = self .project
35
- build_env .version = self .version
33
+ self . build_env = namedtuple ('project' , 'version' )
34
+ self . build_env .project = self .project
35
+ self . build_env .version = self .version
36
36
37
37
BaseSphinx .type = 'base'
38
38
BaseSphinx .sphinx_build_dir = tempfile .mkdtemp ()
39
39
40
- python_env = Virtualenv (
41
- version = self .version ,
42
- build_env = build_env ,
43
- config = None ,
44
- )
45
- self .base_sphinx = BaseSphinx (
46
- build_env = build_env ,
47
- python_env = python_env ,
48
- )
49
-
50
40
@patch (
51
41
'readthedocs.doc_builder.backends.sphinx.SPHINX_TEMPLATE_DIR' ,
52
42
'/tmp/sphinx-template-dir' ,
@@ -57,7 +47,8 @@ def setUp(self):
57
47
@patch ('readthedocs.doc_builder.backends.sphinx.BaseSphinx.run' )
58
48
@patch ('readthedocs.builds.models.Version.get_conf_py_path' )
59
49
@patch ('readthedocs.builds.models.Project.conf_file' )
60
- def test_create_conf_py (self , conf_file , get_conf_py_path , _ , get_config_params , create_index , docs_dir ):
50
+ @patch ('readthedocs.projects.models.Project.checkout_path' )
51
+ def test_create_conf_py (self , checkout_path , conf_file , get_conf_py_path , _ , get_config_params , create_index , docs_dir ):
61
52
"""
62
53
Test for a project without ``conf.py`` file.
63
54
@@ -69,20 +60,35 @@ def test_create_conf_py(self, conf_file, get_conf_py_path, _, get_config_params,
69
60
any kind of exception raised by ``append_conf`` (we were originally
70
61
having a ``TypeError`` because of an encoding problem in Python3)
71
62
"""
63
+ checkout_path .return_value = tempfile .mkdtemp ()
72
64
docs_dir .return_value = tempfile .mkdtemp ()
73
65
create_index .return_value = 'README.rst'
74
66
get_config_params .return_value = {}
75
67
get_conf_py_path .side_effect = ProjectConfigurationError
76
68
conf_file .return_value = tempfile .mktemp ()
69
+ python_env = Virtualenv (
70
+ version = self .version ,
71
+ build_env = self .build_env ,
72
+ config = None ,
73
+ )
74
+ base_sphinx = BaseSphinx (
75
+ build_env = self .build_env ,
76
+ python_env = python_env ,
77
+ )
77
78
try :
78
- self . base_sphinx .append_conf ()
79
+ base_sphinx .append_conf ()
79
80
except Exception :
80
81
pytest .fail ('Exception was generated when append_conf called.' )
81
82
82
83
# Check the content generated by our method is the same than what we
83
84
# expects from a pre-generated file
84
- generated_conf_py = os .path .join (self .base_sphinx .docs_dir (), 'conf.py' )
85
- expected_conf_py = os .path .join (os .path .dirname (__file__ ), '..' , 'files' , 'conf.py' )
85
+ generated_conf_py = os .path .join (base_sphinx .docs_dir (), 'conf.py' )
86
+ expected_conf_py = os .path .join (
87
+ os .path .dirname (__file__ ),
88
+ '..' ,
89
+ 'files' ,
90
+ 'conf.py'
91
+ )
86
92
with open (generated_conf_py ) as gf , open (expected_conf_py ) as ef :
87
93
self .assertEqual (gf .read (), ef .read ())
88
94
@@ -95,21 +101,13 @@ def setUp(self):
95
101
self .project = Project .objects .get (slug = 'pip' )
96
102
self .version = self .project .versions .first ()
97
103
98
- build_env = namedtuple ('project' , 'version' )
99
- build_env .project = self .project
100
- build_env .version = self .version
101
-
102
- python_env = Virtualenv (
103
- version = self .version ,
104
- build_env = build_env ,
105
- config = None ,
106
- )
107
- self .searchbuilder = SearchBuilder (
108
- build_env = build_env ,
109
- python_env = python_env ,
110
- )
104
+ self .build_env = namedtuple ('project' , 'version' )
105
+ self .build_env .project = self .project
106
+ self .build_env .version = self .version
111
107
112
- def test_ignore_patterns (self ):
108
+ @patch ('readthedocs.projects.models.Project.checkout_path' )
109
+ def test_ignore_patterns (self , checkout_path ):
110
+ checkout_path .return_value = tempfile .mkdtemp ()
113
111
src = tempfile .mkdtemp ()
114
112
src_static = os .path .join (src , '_static/' )
115
113
src_other = os .path .join (src , 'other/' )
@@ -120,14 +118,24 @@ def test_ignore_patterns(self):
120
118
dest_static = os .path .join (dest , '_static/' )
121
119
dest_other = os .path .join (dest , 'other/' )
122
120
123
- self .searchbuilder .old_artifact_path = src
124
- self .searchbuilder .target = dest
121
+ python_env = Virtualenv (
122
+ version = self .version ,
123
+ build_env = self .build_env ,
124
+ config = None ,
125
+ )
126
+ searchbuilder = SearchBuilder (
127
+ build_env = self .build_env ,
128
+ python_env = python_env ,
129
+ )
130
+
131
+ searchbuilder .old_artifact_path = src
132
+ searchbuilder .target = dest
125
133
126
134
# There is a _static/ dir in src/ but not in dest/
127
135
self .assertTrue (os .path .exists (src_static ))
128
136
self .assertFalse (os .path .exists (dest_static ))
129
137
130
- self . searchbuilder .move ()
138
+ searchbuilder .move ()
131
139
132
140
# There is a dest/other/ but not a dest/_static
133
141
self .assertFalse (os .path .exists (dest_static ))
0 commit comments