Skip to content

Commit

Permalink
Add test to ensure bootstrap reqs are good
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Jan 8, 2025
1 parent 5607961 commit afd7f44
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions awx/main/tests/functional/test_python_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@
from django.conf import settings


def test_bootstrap_consistent():
with open('Makefile', 'r') as f:
mk_data = f.read()
bootstrap_reqs = None

Check warning on line 11 in awx/main/tests/functional/test_python_requirements.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/test_python_requirements.py#L9-L11

Added lines #L9 - L11 were not covered by tests
for line in mk_data.split('\n'):
if line.startswith('VENV_BOOTSTRAP'):
parts = line.split()
bootstrap_reqs = parts[parts.index('?=') + 1 :]
break

Check warning on line 16 in awx/main/tests/functional/test_python_requirements.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/test_python_requirements.py#L14-L16

Added lines #L14 - L16 were not covered by tests
else:
raise RuntimeError('Cound not find bootstrap line')

Check warning on line 18 in awx/main/tests/functional/test_python_requirements.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/test_python_requirements.py#L18

Added line #L18 was not covered by tests

req_data = None
with open('requirements/requirements.txt', 'r') as f:
req_data = f.read()

Check warning on line 22 in awx/main/tests/functional/test_python_requirements.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/test_python_requirements.py#L20-L22

Added lines #L20 - L22 were not covered by tests

for req in bootstrap_reqs:
boot_req_name, _ = req.split('=', 1)

Check warning on line 25 in awx/main/tests/functional/test_python_requirements.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/test_python_requirements.py#L25

Added line #L25 was not covered by tests
for line in req_data.split('\n'):
if '=' not in line:
continue
req_name, _ = line.split('=', 1)

Check warning on line 29 in awx/main/tests/functional/test_python_requirements.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/test_python_requirements.py#L28-L29

Added lines #L28 - L29 were not covered by tests
if req_name == boot_req_name:
assert req == line
break

Check warning on line 32 in awx/main/tests/functional/test_python_requirements.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/test_python_requirements.py#L31-L32

Added lines #L31 - L32 were not covered by tests


@pytest.mark.skip(reason="This test needs some love")
def test_env_matches_requirements_txt():
from pip.operations import freeze
Expand Down

0 comments on commit afd7f44

Please sign in to comment.