@@ -604,49 +604,71 @@ def test_delete_all_identities__deletes_all_identities_documents_from_dynamodb(
604604
605605
606606@pytest .mark .parametrize (
607- "identity_features" ,
607+ "identity_features, expected_counts " ,
608608 [
609- [[1 , 2 , 3 ], [99 ], []],
610- [[1 , 2 , 3 ], [99 ], [1 , 2 , 3 , 99 ]],
611- [[], [], []],
612- [[], [1 , 2 , 3 ], []],
613- [[4 ], [4 , 25 , 18 , 19 , 85 , 100 ], [4 ]],
609+ (
610+ [[1 , 2 , 3 ], [99 ], []],
611+ {1 : 1 , 2 : 1 , 3 : 1 , 99 : 1 },
612+ ),
613+ (
614+ [[1 , 2 , 3 ], [99 ], [1 , 2 , 3 , 99 ]],
615+ {1 : 2 , 2 : 2 , 3 : 2 , 99 : 2 },
616+ ),
617+ (
618+ [[], [], []],
619+ {},
620+ ),
621+ (
622+ [[], [1 , 2 , 3 ], []],
623+ {1 : 1 , 2 : 1 , 3 : 1 },
624+ ),
625+ (
626+ [[4 ], [4 , 25 , 18 , 19 , 85 , 100 ], [4 ]],
627+ {4 : 3 , 25 : 1 , 18 : 1 , 19 : 1 , 85 : 1 , 100 : 1 },
628+ ),
614629 ],
615630)
616- def test_get_identity_overrides_count_dynamo_returns_correct_total (
631+ def test_get_identity_override_feature_counts_dynamo_returns_correct_total (
617632 flagsmith_identities_table : Table ,
618633 dynamodb_identity_wrapper : DynamoIdentityWrapper ,
619634 identity_features : list [list [int ]],
635+ expected_counts : dict [int , int ],
620636) -> None :
621637 environment_api_key = "env_test"
622638
623639 identity_one = {
624640 "composite_key" : f"{ environment_api_key } _identity1" ,
625641 "environment_api_key" : environment_api_key ,
626642 "identifier" : "user1" ,
627- "identity_features" : identity_features [0 ],
643+ "identity_features" : [
644+ {"feature" : {"id" : feature_id }} for feature_id in identity_features [0 ]
645+ ],
628646 }
629647
630648 identity_two = {
631649 "composite_key" : f"{ environment_api_key } _identity2" ,
632650 "environment_api_key" : environment_api_key ,
633651 "identifier" : "user2" ,
634- "identity_features" : identity_features [1 ],
652+ "identity_features" : [
653+ {"feature" : {"id" : feature_id }} for feature_id in identity_features [1 ]
654+ ],
635655 }
636656
637657 identity_three = {
638658 "composite_key" : f"{ environment_api_key } _identity3" ,
639659 "environment_api_key" : environment_api_key ,
640660 "identifier" : "user3" ,
641- "identity_features" : identity_features [2 ],
661+ "identity_features" : [
662+ {"feature" : {"id" : feature_id }} for feature_id in identity_features [2 ]
663+ ],
642664 }
643665
644666 flagsmith_identities_table .put_item (Item = identity_one )
645667 flagsmith_identities_table .put_item (Item = identity_two )
646668 flagsmith_identities_table .put_item (Item = identity_three )
647669
648- result = dynamodb_identity_wrapper .get_identity_overrides_count (environment_api_key )
649-
650- assert result == len (identity_features [0 ]) + len (identity_features [1 ]) + len (
651- identity_features [2 ]
670+ result = dynamodb_identity_wrapper .get_identity_override_feature_counts (
671+ environment_api_key
652672 )
673+
674+ assert result == expected_counts
0 commit comments