Exception message and tests
parent
534ef08aee
commit
d0cda1da89
|
@ -15,6 +15,12 @@ class ProjectConfigurationError(BuildEnvironmentError):
|
|||
'Make sure you have a conf.py file in your repository.'
|
||||
)
|
||||
|
||||
MULTIPLE_CONF_FILES = _(
|
||||
"There are more than one conf.py file and none of them say doc "
|
||||
"in their path, we don't know which one use. Please, select "
|
||||
"the correct one under the Advanced settings tab in the "
|
||||
"project's Admin."
|
||||
)
|
||||
|
||||
class RepositoryError(BuildEnvironmentError):
|
||||
|
||||
|
|
|
@ -541,11 +541,9 @@ class Project(models.Model):
|
|||
# If the project has more than one conf.py file but none of them have
|
||||
# the `doc` word in the path, we raise an error informing this to the user
|
||||
if len(files) > 1:
|
||||
raise ProjectConfigurationError(_(
|
||||
"There are more than one conf.py file and none of them say doc "
|
||||
"in their path, we don't know which one use. Please, select "
|
||||
"the correct one under the Advanced settings tab in the "
|
||||
"project's Admin."))
|
||||
raise ProjectConfigurationError(
|
||||
ProjectConfigurationError.MULTIPLE_CONF_FILES
|
||||
)
|
||||
|
||||
raise ProjectConfigurationError(
|
||||
ProjectConfigurationError.NOT_FOUND
|
||||
|
|
|
@ -7,11 +7,13 @@ import json
|
|||
|
||||
from django.test import TestCase
|
||||
from django_dynamic_fixture import get
|
||||
from mock import patch
|
||||
from rest_framework.reverse import reverse
|
||||
|
||||
from readthedocs.builds.constants import (
|
||||
BUILD_STATE_CLONING, BUILD_STATE_FINISHED, BUILD_STATE_TRIGGERED, LATEST)
|
||||
from readthedocs.builds.models import Build
|
||||
from readthedocs.projects.exceptions import ProjectConfigurationError
|
||||
from readthedocs.projects.models import Project
|
||||
from readthedocs.projects.tasks import finish_inactive_builds
|
||||
from readthedocs.rtd_tests.mocks.paths import fake_paths_by_regex
|
||||
|
@ -116,6 +118,45 @@ class TestProject(TestCase):
|
|||
with fake_paths_by_regex('\.epub$'):
|
||||
self.assertFalse(self.pip.has_epub(LATEST))
|
||||
|
||||
@patch('readthedocs.projects.models.Project.find')
|
||||
def test_conf_file_found(self, find_method):
|
||||
find_method.return_value = [
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/latest/src/conf.py',
|
||||
]
|
||||
self.assertEqual(
|
||||
self.pip.conf_file(),
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/latest/src/conf.py',
|
||||
)
|
||||
|
||||
@patch('readthedocs.projects.models.Project.find')
|
||||
def test_multiple_conf_file_one_doc_in_path(self, find_method):
|
||||
find_method.return_value = [
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/latest/src/conf.py',
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/latest/docs/conf.py',
|
||||
]
|
||||
self.assertEqual(
|
||||
self.pip.conf_file(),
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/latest/docs/conf.py',
|
||||
)
|
||||
|
||||
def test_conf_file_not_found(self):
|
||||
with self.assertRaisesMessage(
|
||||
ProjectConfigurationError,
|
||||
ProjectConfigurationError.NOT_FOUND) as cm:
|
||||
self.pip.conf_file()
|
||||
|
||||
@patch('readthedocs.projects.models.Project.find')
|
||||
def test_multiple_conf_files(self, find_method):
|
||||
find_method.return_value = [
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/multi-conf.py/src/conf.py',
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/multi-conf.py/src/sub/conf.py',
|
||||
'/home/docs/rtfd/code/readthedocs.org/user_builds/pip/checkouts/multi-conf.py/src/sub/src/conf.py',
|
||||
]
|
||||
with self.assertRaisesMessage(
|
||||
ProjectConfigurationError,
|
||||
ProjectConfigurationError.MULTIPLE_CONF_FILES) as cm:
|
||||
self.pip.conf_file()
|
||||
|
||||
|
||||
class TestFinishInactiveBuildsTask(TestCase):
|
||||
fixtures = ['eric', 'test_data']
|
||||
|
|
Loading…
Reference in New Issue