Skip to content

Commit

Permalink
Add start and termination to YAML file regex (#4584)
Browse files Browse the repository at this point in the history
* Add start and termination to YAML file regex

Otherwise it found files like:

  .hg/store/data/readthedocs.yml.i

* Update common submodule

* Tests (#4587)
  • Loading branch information
humitos authored and agjohnson committed Aug 29, 2018
1 parent b6bd7a6 commit dcb4270
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common
2 changes: 1 addition & 1 deletion readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)

ALL = 'all'
CONFIG_FILENAME_REGEX = r'\.?readthedocs.ya?ml'
CONFIG_FILENAME_REGEX = r'^\.?readthedocs.ya?ml$'

CONFIG_NOT_SUPPORTED = 'config-not-supported'
VERSION_INVALID = 'version-invalid'
Expand Down
20 changes: 15 additions & 5 deletions readthedocs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from __future__ import division, print_function, unicode_literals

import os
import textwrap
import re
import textwrap

import pytest
from mock import DEFAULT, patch
Expand All @@ -13,8 +13,8 @@
ALL, BuildConfigV1, BuildConfigV2, ConfigError,
ConfigOptionNotSupportedError, InvalidConfig, ProjectConfig, load)
from readthedocs.config.config import (
CONFIG_NOT_SUPPORTED, NAME_INVALID, NAME_REQUIRED, PYTHON_INVALID,
VERSION_INVALID, CONFIG_FILENAME_REGEX)
CONFIG_FILENAME_REGEX, CONFIG_NOT_SUPPORTED, CONFIG_REQUIRED, NAME_INVALID,
NAME_REQUIRED, PYTHON_INVALID, VERSION_INVALID)
from readthedocs.config.models import Conda
from readthedocs.config.validation import (
INVALID_BOOL, INVALID_CHOICE, INVALID_LIST, INVALID_PATH, INVALID_STRING)
Expand Down Expand Up @@ -81,10 +81,20 @@ def get_env_config(extra=None):
return defaults


def test_load_no_config_file(tmpdir):
@pytest.mark.parametrize('files', [
{},
{'readthedocs.ymlmore': ''},
{'startreadthedocs.yml': ''},
{'noroot': {'readthedocs.ymlmore': ''}},
{'noroot': {'startreadthedocs.yml': ''}},
{'readthebots.yaml': ''},
])
def test_load_no_config_file(tmpdir, files):
apply_fs(tmpdir, files)
base = str(tmpdir)
with raises(ConfigError):
with raises(ConfigError) as e:
load(base, env_config)
assert e.value.code == CONFIG_REQUIRED


def test_load_empty_config_file(tmpdir):
Expand Down

0 comments on commit dcb4270

Please sign in to comment.