Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to ensure bootstrap reqs are good #15733

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 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,36 @@
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

different_requirements = []

Check warning on line 24 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#L24

Added line #L24 was not covered by tests
for req in bootstrap_reqs:
boot_req_name, _ = req.split('=', 1)

Check warning on line 26 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#L26

Added line #L26 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 30 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#L29-L30

Added lines #L29 - L30 were not covered by tests
if req_name == boot_req_name:
different_requirements.append((req, line))
break

Check warning on line 33 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#L32-L33

Added lines #L32 - L33 were not covered by tests

assert not different_requirements

Check warning on line 35 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#L35

Added line #L35 was 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
Loading