|
26 | 26 | CONFIG_REQUIRED,
|
27 | 27 | CONFIG_SYNTAX_INVALID,
|
28 | 28 | INVALID_KEY,
|
| 29 | + INVALID_NAME, |
29 | 30 | PYTHON_INVALID,
|
30 | 31 | VERSION_INVALID,
|
31 | 32 | )
|
@@ -748,6 +749,7 @@ def test_as_dict(tmpdir):
|
748 | 749 | },
|
749 | 750 | 'build': {
|
750 | 751 | 'image': 'readthedocs/build:latest',
|
| 752 | + 'apt_packages': [], |
751 | 753 | },
|
752 | 754 | 'conda': None,
|
753 | 755 | 'sphinx': {
|
@@ -935,6 +937,62 @@ def test_build_image_check_invalid_type(self, value):
|
935 | 937 | build.validate()
|
936 | 938 | assert excinfo.value.key == 'build.image'
|
937 | 939 |
|
| 940 | + @pytest.mark.parametrize( |
| 941 | + 'value', |
| 942 | + [ |
| 943 | + [], |
| 944 | + ['cmatrix'], |
| 945 | + ['Mysql', 'cmatrix', 'postgresql-dev'], |
| 946 | + ], |
| 947 | + ) |
| 948 | + def test_build_apt_packages_check_valid(self, value): |
| 949 | + build = self.get_build_config({'build': {'apt_packages': value}}) |
| 950 | + build.validate() |
| 951 | + assert build.build.apt_packages == value |
| 952 | + |
| 953 | + @pytest.mark.parametrize( |
| 954 | + 'value', |
| 955 | + [3, 'string', {}], |
| 956 | + ) |
| 957 | + def test_build_apt_packages_invalid_type(self, value): |
| 958 | + build = self.get_build_config({'build': {'apt_packages': value}}) |
| 959 | + with raises(InvalidConfig) as excinfo: |
| 960 | + build.validate() |
| 961 | + assert excinfo.value.key == 'build.apt_packages' |
| 962 | + |
| 963 | + @pytest.mark.parametrize( |
| 964 | + 'error_index, value', |
| 965 | + [ |
| 966 | + (0, ['/', 'cmatrix']), |
| 967 | + (1, ['cmatrix', '-q']), |
| 968 | + (1, ['cmatrix', ' -q']), |
| 969 | + (1, ['cmatrix', '\\-q']), |
| 970 | + (1, ['cmatrix', '--quiet']), |
| 971 | + (1, ['cmatrix', ' --quiet']), |
| 972 | + (2, ['cmatrix', 'quiet', './package.deb']), |
| 973 | + (2, ['cmatrix', 'quiet', ' ./package.deb ']), |
| 974 | + (2, ['cmatrix', 'quiet', '/home/user/package.deb']), |
| 975 | + (2, ['cmatrix', 'quiet', ' /home/user/package.deb']), |
| 976 | + (2, ['cmatrix', 'quiet', '../package.deb']), |
| 977 | + (2, ['cmatrix', 'quiet', ' ../package.deb']), |
| 978 | + (1, ['one', '$two']), |
| 979 | + (1, ['one', 'non-ascíí']), |
| 980 | + # We don't allow regex for now. |
| 981 | + (1, ['mysql', 'cmatrix$']), |
| 982 | + (0, ['^mysql-*', 'cmatrix$']), |
| 983 | + # We don't allow specifying versions for now. |
| 984 | + (0, ['postgresql=1.2.3']), |
| 985 | + # We don't allow specifying distributions for now. |
| 986 | + (0, ['cmatrix/bionic']), |
| 987 | + ], |
| 988 | + ) |
| 989 | + def test_build_apt_packages_invalid_value(self, error_index, value): |
| 990 | + build = self.get_build_config({'build': {'apt_packages': value}}) |
| 991 | + with raises(InvalidConfig) as excinfo: |
| 992 | + build.validate() |
| 993 | + assert excinfo.value.key == f'build.apt_packages.{error_index}' |
| 994 | + assert excinfo.value.code == INVALID_NAME |
| 995 | + |
938 | 996 | @pytest.mark.parametrize('value', [3, [], 'invalid'])
|
939 | 997 | def test_python_check_invalid_types(self, value):
|
940 | 998 | build = self.get_build_config({'python': value})
|
@@ -2072,6 +2130,7 @@ def test_as_dict(self, tmpdir):
|
2072 | 2130 | },
|
2073 | 2131 | 'build': {
|
2074 | 2132 | 'image': 'readthedocs/build:latest',
|
| 2133 | + 'apt_packages': [], |
2075 | 2134 | },
|
2076 | 2135 | 'conda': None,
|
2077 | 2136 | 'sphinx': {
|
|
0 commit comments