-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Identity overrides are not deleted when deleting Edge identities (…
- Loading branch information
Showing
4 changed files
with
107 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,40 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
from boto3.dynamodb.conditions import Key | ||
from flag_engine.identities.models import IdentityModel | ||
|
||
from edge_api.identities.models import EdgeIdentity | ||
from environments.dynamodb.wrappers.environment_wrapper import ( | ||
DynamoEnvironmentV2Wrapper, | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def webhook_mock(mocker): | ||
return mocker.patch( | ||
"edge_api.identities.serializers.call_environment_webhook_for_feature_state_change" | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def identity_overrides_v2( | ||
dynamo_enabled_environment: int, | ||
identity_document_without_fs: dict[str, Any], | ||
identity_document: dict[str, Any], | ||
dynamodb_wrapper_v2: DynamoEnvironmentV2Wrapper, | ||
) -> list[str]: | ||
edge_identity = EdgeIdentity.from_identity_document(identity_document_without_fs) | ||
for feature_override in IdentityModel.model_validate( | ||
identity_document | ||
).identity_features: | ||
edge_identity.add_feature_override(feature_override) | ||
edge_identity.save() | ||
return [ | ||
item["document_key"] | ||
for item in dynamodb_wrapper_v2.query_get_all_items( | ||
KeyConditionExpression=Key("environment_id").eq( | ||
str(dynamo_enabled_environment) | ||
), | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters