|
| 1 | +"""Data definitions""" |
| 2 | + |
| 3 | +from pathlib import Path |
| 4 | + |
| 5 | +from cppython.core.schema import ( |
| 6 | + CPPythonGlobalConfiguration, |
| 7 | + CPPythonLocalConfiguration, |
| 8 | + PEP621Configuration, |
| 9 | + ProjectConfiguration, |
| 10 | +) |
| 11 | +from cppython.test.schema import Variant, Variants |
| 12 | + |
| 13 | + |
| 14 | +def _pep621_configuration_list() -> Variants[PEP621Configuration]: |
| 15 | + """Creates a list of mocked configuration types |
| 16 | +
|
| 17 | + Returns: |
| 18 | + A list of variants to test |
| 19 | + """ |
| 20 | + data = Variants[PEP621Configuration]() |
| 21 | + |
| 22 | + # Default |
| 23 | + default = PEP621Configuration(name='default-test', version='1.0.0') |
| 24 | + default_variant = Variant[PEP621Configuration](configuration=default) |
| 25 | + |
| 26 | + data.variants.append(default_variant) |
| 27 | + |
| 28 | + return data |
| 29 | + |
| 30 | + |
| 31 | +def _cppython_local_configuration_list() -> Variants[CPPythonLocalConfiguration]: |
| 32 | + """Mocked list of local configuration data |
| 33 | +
|
| 34 | + Returns: |
| 35 | + A list of variants to test |
| 36 | + """ |
| 37 | + data = Variants[CPPythonLocalConfiguration]() |
| 38 | + |
| 39 | + # Default |
| 40 | + default = CPPythonLocalConfiguration() |
| 41 | + default_variant = Variant[CPPythonLocalConfiguration](configuration=default) |
| 42 | + |
| 43 | + data.variants.append(default_variant) |
| 44 | + |
| 45 | + return data |
| 46 | + |
| 47 | + |
| 48 | +def _cppython_global_configuration_list() -> Variants[CPPythonGlobalConfiguration]: |
| 49 | + """Mocked list of global configuration data |
| 50 | +
|
| 51 | + Returns: |
| 52 | + A list of variants to test |
| 53 | + """ |
| 54 | + data = Variants[CPPythonGlobalConfiguration]() |
| 55 | + |
| 56 | + # Default |
| 57 | + default = CPPythonGlobalConfiguration() |
| 58 | + default_variant = Variant[CPPythonGlobalConfiguration](configuration=default) |
| 59 | + |
| 60 | + # Check off |
| 61 | + check_off_data = {'current-check': False} |
| 62 | + check_off = CPPythonGlobalConfiguration(**check_off_data) |
| 63 | + check_off_variant = Variant[CPPythonGlobalConfiguration](configuration=check_off) |
| 64 | + |
| 65 | + data.variants.append(default_variant) |
| 66 | + data.variants.append(check_off_variant) |
| 67 | + |
| 68 | + return data |
| 69 | + |
| 70 | + |
| 71 | +def _project_configuration_list() -> Variants[ProjectConfiguration]: |
| 72 | + """Mocked list of project configuration data |
| 73 | +
|
| 74 | + Returns: |
| 75 | + A list of variants to test |
| 76 | + """ |
| 77 | + data = Variants[ProjectConfiguration]() |
| 78 | + |
| 79 | + # NOTE: pyproject_file will be overridden by fixture |
| 80 | + |
| 81 | + # Default |
| 82 | + default = ProjectConfiguration(pyproject_file=Path('pyproject.toml'), version='0.1.0') |
| 83 | + default_variant = Variant[ProjectConfiguration](configuration=default) |
| 84 | + |
| 85 | + data.variants.append(default_variant) |
| 86 | + |
| 87 | + return data |
| 88 | + |
| 89 | + |
| 90 | +pep621_variants = _pep621_configuration_list() |
| 91 | +cppython_local_variants = _cppython_local_configuration_list() |
| 92 | +cppython_global_variants = _cppython_global_configuration_list() |
| 93 | +project_variants = _project_configuration_list() |
0 commit comments