|
11 | 11 | from django.core.exceptions import ImproperlyConfigured |
12 | 12 | from mitol.common import envs |
13 | 13 |
|
14 | | -# this is a test, but pylint thinks it ends up being unused |
15 | | -# hence we import the entire module and assign it here |
16 | | -# test_app_json_modified = pytest_utils.test_app_json_modified # noqa: ERA001 |
17 | | - |
18 | | - |
19 | | -# NOTE: this is temporarily inlined here until I can stabilize the test upstream in the library |
20 | | -def test_app_json_modified(): |
21 | | - """ |
22 | | - Pytest test that verifies app.json is up-to-date |
23 | | -
|
24 | | - To use this, you should import this into a test file somewhere in your project: |
25 | | -
|
26 | | - from mitol.common.pytest_utils import test_app_json_modified |
27 | | - """ |
28 | | - import json |
29 | | - import logging |
30 | | - |
31 | | - from mitol.common import envs |
32 | | - |
33 | | - # this line was causing errors due to a loading error bug |
34 | | - # envs.reload() # noqa: ERA001 |
35 | | - |
36 | | - with open("app.json") as app_json_file: # noqa: PTH123 |
37 | | - app_json = json.load(app_json_file) |
38 | | - |
39 | | - generated_app_json = envs.generate_app_json() |
40 | | - |
41 | | - if app_json != generated_app_json: |
42 | | - logging.error( |
43 | | - "Generated app.json does not match the app.json file. To fix this, run `./manage.py generate_app_json`" |
44 | | - ) |
45 | | - |
46 | | - # pytest will print the difference |
47 | | - assert json.dumps(app_json, sort_keys=True, indent=2) == json.dumps( |
48 | | - generated_app_json, sort_keys=True, indent=2 |
49 | | - ) |
50 | | - |
51 | 14 |
|
52 | 15 | @pytest.fixture(autouse=True) |
53 | 16 | def settings_sandbox(monkeypatch): |
|
0 commit comments