Skip to content

Commit 3119831

Browse files
committed
Test to call BaseSphinx.append_conf() without a conf.py
1 parent 78b5781 commit 3119831

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import (
3+
absolute_import, division, print_function, unicode_literals)
4+
5+
from collections import namedtuple
6+
import tempfile
7+
8+
from django.test import TestCase
9+
from mock import patch
10+
11+
from readthedocs.doc_builder.backends.sphinx import BaseSphinx
12+
from readthedocs.projects.exceptions import ProjectConfigurationError
13+
from readthedocs.projects.models import Project
14+
15+
16+
class SphinxBuilderTest(TestCase):
17+
18+
fixtures = ['test_data']
19+
20+
def setUp(self):
21+
self.project = Project.objects.get(slug='pip')
22+
self.version = self.project.versions.first()
23+
24+
build_env = namedtuple('project', 'version')
25+
build_env.project = self.project
26+
build_env.version = self.version
27+
28+
BaseSphinx.type = 'base'
29+
BaseSphinx.sphinx_build_dir = tempfile.mkdtemp()
30+
self.base_sphinx = BaseSphinx(build_env=build_env, python_env=None)
31+
32+
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.create_index')
33+
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.get_config_params')
34+
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.run')
35+
@patch('readthedocs.builds.models.Version.get_conf_py_path')
36+
def test_create_conf_py(self, get_conf_py_path, run, get_config_params, create_index):
37+
create_index.return_value = 'README.rst'
38+
get_config_params.return_vlaue = {}
39+
get_conf_py_path.side_effect = ProjectConfigurationError
40+
self.base_sphinx.append_conf()

0 commit comments

Comments
 (0)