diff --git a/readthedocs/rtd_tests/fixtures/spec/v2/schema.yml b/readthedocs/rtd_tests/fixtures/spec/v2/schema.yml index d192f8c3b76..75022c6c404 100644 --- a/readthedocs/rtd_tests/fixtures/spec/v2/schema.yml +++ b/readthedocs/rtd_tests/fixtures/spec/v2/schema.yml @@ -53,22 +53,30 @@ python: # Default: '3' version: enum('2', '2.7', '3', '3.3', '3.4', '3.5', '3.6', required=False) + # Give the virtual environment access to the global site-packages dir + # Default: false | project config + system_packages: bool(required=False) + + # Installation of packages and requiremens + install: list(any(include('python-install-requirements'), include('python-install')), required=False) + +python-install-requirements: # The path to the requirements file from the root of the project - # Default: null | project config - requirements: path(required=False) + requirements: path() - # Install the project using python setup.py install or pip - # Default: null | project config - install: enum('pip', 'setup.py', required=False) +python-install: + # The path to the project to be installed + path: path() - # Extra requirements sections to install in addition to the package dependencies + # Install using python setup.py install or pip + # Default: pip + method: enum('pip', 'setuptools', required=False) + + # Extra requirements sections to install in addition to the package dependencies. + # Only valid when `method` is `pip`. # Default: [] extra_requirements: list(str(), required=False) - # Give the virtual environment access to the global site-packages dir - # Default: false | project config - system_packages: bool(required=False) - sphinx: # The builder type for the sphinx documentation # Default: 'html' diff --git a/readthedocs/rtd_tests/tests/test_build_config.py b/readthedocs/rtd_tests/tests/test_build_config.py index 11afa046711..880b4fae686 100644 --- a/readthedocs/rtd_tests/tests/test_build_config.py +++ b/readthedocs/rtd_tests/tests/test_build_config.py @@ -74,7 +74,7 @@ def assertInvalidConfig(tmpdir, content, msgs=()): with pytest.raises(ValueError) as excinfo: validate_schema(file) for msg in msgs: - msg in str(excinfo.value) + assert msg in str(excinfo.value) def test_minimal_config(tmpdir): @@ -250,16 +250,18 @@ def test_python_requirements(tmpdir): content = ''' version: "2" python: - requirements: docs/requirements.txt + install: + - requirements: docs/requirements.txt ''' assertValidConfig(tmpdir, content) -def test_python_requirements_invalid(tmpdir): +def test_python_install_requirements(tmpdir): content = ''' version: "2" python: - requirements: 23 + install: + - requirements: 23 ''' assertInvalidConfig( tmpdir, @@ -268,22 +270,15 @@ def test_python_requirements_invalid(tmpdir): ) -def test_python_requirements_null(tmpdir): - content = ''' -version: "2" -python: - requirements: null - ''' - assertValidConfig(tmpdir, content) - - -@pytest.mark.parametrize('value', ['pip', 'setup.py']) +@pytest.mark.parametrize('value', ['pip', 'setuptools']) def test_python_install(tmpdir, value): content = ''' version: "2" python: version: "3.6" - install: {value} + install: + - path: . + method: {value} ''' assertValidConfig(tmpdir, content.format(value=value)) @@ -297,7 +292,7 @@ def test_python_install_invalid(tmpdir): assertInvalidConfig( tmpdir, content, - ["python.install: 'guido' not in"] + ["python.install: 'guido' is not a list"] ) @@ -310,38 +305,27 @@ def test_python_install_null(tmpdir): assertValidConfig(tmpdir, content) -def test_python_extra_requirements(tmpdir): +def test_python_install_extra_requirements(tmpdir): content = ''' version: "2" python: - extra_requirements: - - test - - dev + install: + - path: . + extra_requirements: + - test + - dev ''' assertValidConfig(tmpdir, content) -def test_python_extra_requirements_invalid(tmpdir): - content = ''' -version: "2" -python: - extra_requirements: - - 1 - - dev - ''' - assertInvalidConfig( - tmpdir, - content, - ["'1' is not a str"] - ) - - @pytest.mark.parametrize('value', ['', 'null', '[]']) def test_python_extra_requirements_empty(tmpdir, value): content = ''' version: "2" python: - extra_requirements: {value} + install: + - path: . + extra_requirements: {value} ''' assertValidConfig(tmpdir, content.format(value=value))