1010from django .db .models import Count , Q
1111from django .test import override_settings
1212from django .utils import timezone
13+ from flagsmith_schemas .api import V1EnvironmentDocumentResponse
1314from mypy_boto3_dynamodb .service_resource import Table
1415from pytest_django import DjangoAssertNumQueries
1516from pytest_django .asserts import assertQuerySetEqual as assert_queryset_equal
1920from audit .related_object_type import RelatedObjectType
2021from core .constants import STRING
2122from core .request_origin import RequestOrigin
22- from environments .identities .models import Identity
2323from environments .enums import EnvironmentDocumentCacheMode
24- from flagsmith_schemas . api import V1EnvironmentDocumentResponse
24+ from environments . identities . models import Identity
2525from environments .metrics import CACHE_HIT , CACHE_MISS
2626from environments .models import (
2727 Environment ,
@@ -1269,7 +1269,7 @@ def test_environment_clone_from_non_versioned_environment_with_use_v2_feature_ve
12691269 # When
12701270 new_environment = environment .clone (name = "new-environment" )
12711271
1272- # Then
1272+ # Then
12731273 assert new_environment .use_v2_feature_versioning
12741274
12751275 # we only expect a single environment feature version as we are essentially
@@ -1283,15 +1283,14 @@ def test_environment_clone_from_non_versioned_environment_with_use_v2_feature_ve
12831283 assert latest_feature_states .count () == 2
12841284 assert {fs .environment_feature_version for fs in latest_feature_states } == {efv }
12851285
1286+
12861287@mock .patch ("environments.models.environment_document_cache" )
12871288def test_write_environment_documents_strips_internal_fields_from_cache (
1288- mock_document_cache : MagicMock ,
1289- environment : Environment ,
1290- settings : typing .Any
1289+ mock_document_cache : MagicMock , environment : Environment , settings : typing .Any
12911290) -> None :
12921291 # 1. SETUP: Force the persistent caching mode
12931292 settings .CACHE_ENVIRONMENT_DOCUMENT_MODE = EnvironmentDocumentCacheMode .PERSISTENT
1294-
1293+
12951294 # 2. ACTION: Trigger the document builder
12961295 Environment .write_environment_documents (environment_id = environment .id )
12971296
@@ -1304,7 +1303,7 @@ def test_write_environment_documents_strips_internal_fields_from_cache(
13041303 assert "compress_dynamo_documents" not in cached_document
13051304 assert "use_v2_feature_versioning" not in cached_document
13061305
1307- # 5. SCHEMA VALIDATION: Prove the dictionary perfectly matches the TypedDict
1306+ # 5. SCHEMA VALIDATION: Prove the dictionary perfectly matches the TypedDict
13081307 # required by the API. If this raises an error, the fix failed.
13091308 clean_doc : V1EnvironmentDocumentResponse = {
13101309 "api_key" : cached_document ["api_key" ],
0 commit comments