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

[AAP-39138] - Add DAB Feature Flag common API #15786

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pytest
from django.test import override_settings

from awx.main.models import User


@pytest.mark.django_db
def test_feature_flags_list_endpoint(get):
bob = User.objects.create(username='bob', password='test_user', is_superuser=False)

Check warning on line 9 in awx/main/tests/functional/dab_feature_flags/test_feature_flags_api.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/dab_feature_flags/test_feature_flags_api.py#L9

Added line #L9 was not covered by tests

url = "/api/v2/feature_flags_state/"
response = get(url, user=bob, expect=200)
assert len(response.data) == 1

Check warning on line 13 in awx/main/tests/functional/dab_feature_flags/test_feature_flags_api.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/dab_feature_flags/test_feature_flags_api.py#L11-L13

Added lines #L11 - L13 were not covered by tests


@override_settings(
FLAGS={
"FEATURE_SOME_PLATFORM_FLAG_ENABLED": [
{"condition": "boolean", "value": False},
{"condition": "before date", "value": "2022-06-01T12:00Z"},
],
"FEATURE_SOME_PLATFORM_FLAG_FOO_ENABLED": [
{"condition": "boolean", "value": True},
],
}
)
@pytest.mark.django_db
def test_feature_flags_list_endpoint_override(get):
bob = User.objects.create(username='bob', password='test_user', is_superuser=False)

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

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/dab_feature_flags/test_feature_flags_api.py#L29

Added line #L29 was not covered by tests

url = "/api/v2/feature_flags_state/"
response = get(url, user=bob, expect=200)
assert len(response.data) == 2
assert response.data["FEATURE_SOME_PLATFORM_FLAG_ENABLED"] is False
assert response.data["FEATURE_SOME_PLATFORM_FLAG_FOO_ENABLED"] is True

Check warning on line 35 in awx/main/tests/functional/dab_feature_flags/test_feature_flags_api.py

View check run for this annotation

Codecov / codecov/patch

awx/main/tests/functional/dab_feature_flags/test_feature_flags_api.py#L31-L35

Added lines #L31 - L35 were not covered by tests
1 change: 1 addition & 0 deletions awx/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
'ansible_base.jwt_consumer',
'ansible_base.resource_registry',
'ansible_base.rbac',
'ansible_base.feature_flags',
'flags',
]

Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements_git.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
git+https://github.com/ansible/system-certifi.git@devel#egg=certifi
# Remove pbr from requirements.in when moving ansible-runner to requirements.in
git+https://github.com/ansible/ansible-runner.git@devel#egg=ansible-runner
django-ansible-base @ git+https://github.com/ansible/django-ansible-base@devel#egg=django-ansible-base[rest-filters,jwt_consumer,resource-registry,rbac]
django-ansible-base @ git+https://github.com/ansible/django-ansible-base@devel#egg=django-ansible-base[rest-filters,jwt_consumer,resource-registry,rbac,feature-flags]
awx-plugins-core @ git+https://github.com/ansible/awx-plugins.git@devel#egg=awx-plugins-core
awx_plugins.interfaces @ git+https://github.com/ansible/awx_plugins.interfaces.git
Loading