def test_conf_py_path(self, checkout_path, docs_dir): """ Test the conf_py_path that is added to the conf.py file. This value is used from the theme and footer to build the ``View`` and ``Edit`` on link. """ tmp_dir = tempfile.mkdtemp() checkout_path.return_value = tmp_dir docs_dir.return_value = tmp_dir python_env = Virtualenv( version=self.version, build_env=self.build_env, config=None, ) base_sphinx = BaseSphinx( build_env=self.build_env, python_env=python_env, ) for value, expected in (('conf.py', '/'), ('docs/conf.py', '/docs/')): base_sphinx.config_file = os.path.join( tmp_dir, value, ) params = base_sphinx.get_config_params() self.assertEqual( params['conf_py_path'], expected, )
def test_html_context_only_has_public_versions( self, checkout_path, get_conf_py_path, docs_dir, api_project, api_version, ): tmp_dir = tempfile.mkdtemp() checkout_path.return_value = tmp_dir docs_dir.return_value = tmp_dir get_conf_py_path.side_effect = ProjectConfigurationError api_version.version().get.return_value = {'downloads': []} api_project.project().active_versions.get.return_value = { 'versions': [ { 'slug': 'v1', 'privacy_level': PUBLIC, }, { 'slug': 'v2', 'privacy_level': PUBLIC, }, { 'slug': 'v3', 'privacy_level': PRIVATE, }, { 'slug': 'latest', 'privacy_level': PRIVATE, }, ], } python_env = Virtualenv( version=self.version, build_env=self.build_env, config=None, ) base_sphinx = BaseSphinx( build_env=self.build_env, python_env=python_env, ) base_sphinx.config_file = tempfile.mktemp() context = base_sphinx.get_config_params() versions = {v.slug for v in context['versions']} self.assertEqual(versions, {'v1', 'v2'})
def test_conf_py_external_version(self, checkout_path, docs_dir): self.version.type = EXTERNAL self.version.verbose_name = '123' self.version.save() tmp_dir = tempfile.mkdtemp() checkout_path.return_value = tmp_dir docs_dir.return_value = tmp_dir python_env = Virtualenv( version=self.version, build_env=self.build_env, config=None, ) base_sphinx = BaseSphinx( build_env=self.build_env, python_env=python_env, ) base_sphinx.config_file = os.path.join(tmp_dir, 'config.py') params = base_sphinx.get_config_params() self.assertEqual(params['current_version'], '123') self.assertEqual(params['version'], self.version) self.assertEqual(params['build_url'], 'https://readthedocs.org/projects/pip/builds/123/')