Skip to content

Commit

Permalink
Add a test that get_overrides_data gets passed the feature ids
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed Nov 18, 2024
1 parent 8d864f2 commit 5a5e7e4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions api/tests/unit/features/test_unit_features_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
VIEW_ENVIRONMENT,
)
from environments.permissions.models import UserEnvironmentPermission
from features.dataclasses import EnvironmentFeatureOverridesData
from features.feature_types import MULTIVARIATE
from features.models import Feature, FeatureSegment, FeatureState
from features.multivariate.models import MultivariateFeatureOption
Expand Down Expand Up @@ -2062,6 +2063,38 @@ def test_list_features_provides_segment_overrides_for_dynamo_enabled_project(
assert response_json["results"][0]["num_identity_overrides"] is None


def test_list_features_calls_get_overrides_data_with_feature_ids(
dynamo_enabled_project: Project,
dynamo_enabled_project_environment_one: Environment,
admin_client_new: APIClient,
mocker: MockerFixture,
) -> None:
# Given
feature = Feature.objects.create(
name="test_feature", project=dynamo_enabled_project
)
url = "%s?environment=%d" % (
reverse(
"api-v1:projects:project-features-list", args=[dynamo_enabled_project.id]
),
dynamo_enabled_project_environment_one.id,
)
mock_get_overrides_data = mocker.patch("features.views.get_overrides_data")
mock_get_overrides_data.return_value = {
feature.id: EnvironmentFeatureOverridesData()
}

# When
response = admin_client_new.get(url)

# Then
assert response.status_code == status.HTTP_200_OK
mock_get_overrides_data.assert_called_once_with(
dynamo_enabled_project_environment_one,
[feature.id],
)


def test_create_segment_override_reaching_max_limit(
admin_client_new: APIClient,
feature: Feature,
Expand Down

0 comments on commit 5a5e7e4

Please sign in to comment.