@@ -1050,21 +1050,22 @@ def test_hash_validity_with_notifications_enabled(self) -> None:
10501050
10511051 def _test_hash_validity (self ):
10521052 self .maxDiff = None
1053- project1 = '67bc798b-a34a-4104-8cab-cad648471f69'
1054- project2 = '6615efae-fca8-4dd2-a223-9cfcf30fe94d'
1055- project3 = '091cf39b-01bc-42e5-9437-f419a66c8a45'
1056- bundles = {
1057- project1 : self . bundle_fqid ( uuid = 'f79257a7-dfc6-46d6-ae00-ba4b25313c10' ,
1058- version = '2018-09-14T13:33:14.453337Z' ) ,
1059- project2 : self . bundle_fqid ( uuid = '587d74b4-1075-4bbf-b96a-4d1ede0481b2' ,
1060- version = '2018-09-14T13:33:14.453337Z' ),
1061- project3 : self .bundle_fqid (uuid = 'cfab8304-dc9f-439e-af29-f8eb75b0729d' ,
1062- version = '2019-07-18T21:28:20.595913Z' ),
1053+ bundles_by_project = {
1054+ '67bc798b-a34a-4104-8cab-cad648471f69' :
1055+ self . bundle_fqid ( uuid = 'f79257a7-dfc6-46d6-ae00-ba4b25313c10' ,
1056+ version = '2018-09-14T13:33:14.453337Z' ),
1057+ '6615efae-fca8-4dd2-a223-9cfcf30fe94d' :
1058+ self . bundle_fqid ( uuid = '587d74b4-1075-4bbf-b96a-4d1ede0481b2' ,
1059+ version = '2018-09-14T13:33:14.453337Z' ) ,
1060+ '091cf39b-01bc-42e5-9437-f419a66c8a45' :
1061+ self .bundle_fqid (uuid = 'cfab8304-dc9f-439e-af29-f8eb75b0729d' ,
1062+ version = '2019-07-18T21:28:20.595913Z' ),
10631063 }
1064- self ._index_canned_bundle (bundles [project1 ])
1064+ projects , bundles = zip (* bundles_by_project .items ())
1065+ self ._index_canned_bundle (bundles [0 ])
10651066 filters = self ._filters (cast (FiltersJSON , {
10661067 'projectId' : {
1067- 'is' : [project1 , project2 ]
1068+ 'is' : [projects [ 0 ], projects [ 1 ] ]
10681069 }
10691070 }))
10701071 service = ManifestService (self .storage_service , self .app_module .app .file_url )
@@ -1073,37 +1074,35 @@ def manifest_generator(format: ManifestFormat) -> ManifestGenerator:
10731074 generator_cls = ManifestGenerator .cls_for_format (format )
10741075 return generator_cls (service , self .catalog , filters )
10751076
1076- keys = {}
1077+ keys = [{}, {}]
10771078
10781079 for format in ManifestFormat :
10791080 with self .subTest ('First bundle indexed' , format = format ):
1080- # When a new bundle is indexed and its compact manifest cached,
1081- # a matching manifest key is generated ...
1081+ # A manifest for a filter matching files in the first bundle …
10821082 generator = manifest_generator (format )
10831083 manifest_key = generator .manifest_key ()
1084- # and should remain valid ...
1084+ # … should remain cached …
10851085 self .assertEqual (manifest_key , generator .manifest_key ())
1086- keys [( 1 , format ) ] = manifest_key
1086+ keys [0 ][ format ] = manifest_key
10871087
1088- # ... until a new bundle that will match the filter is indexed, at
1089- # which point a manifest request will generate a different key ...
1090- self ._index_canned_bundle (bundles [project2 ])
1088+ # … until a new bundle with files also matching the filter is indexed.
1089+ self ._index_canned_bundle (bundles [1 ])
10911090 for format in ManifestFormat :
10921091 with self .subTest ('Second bundle indexed' , format = format ):
10931092 generator = manifest_generator (format )
10941093 manifest_key = generator .manifest_key ()
1095- # ... invalidating the cached object previously used for the same filter .
1096- self .assertNotEqual (keys [( 1 , format ) ], manifest_key )
1097- keys [( 2 , format ) ] = manifest_key
1094+ # The updated manifest is cached under a different key .
1095+ self .assertNotEqual (keys [0 ][ format ], manifest_key )
1096+ keys [1 ][ format ] = manifest_key
10981097
1099- # Updates or additions, unrelated to that project do not affect object
1100- # key generation
1101- self ._index_canned_bundle (bundles [project3 ])
1098+ # After indexing a bundle with files that don't match the filter, the
1099+ # cached manifest remains valid.
1100+ self ._index_canned_bundle (bundles [2 ])
11021101 for format in ManifestFormat :
11031102 with self .subTest ('Unrelated bundle indexed' , format = format ):
11041103 generator = manifest_generator (format )
11051104 manifest_key = generator .manifest_key ()
1106- self .assertEqual (keys [( 2 , format ) ], manifest_key )
1105+ self .assertEqual (keys [1 ][ format ], manifest_key )
11071106
11081107 @patch .object (StorageService , '_time_until_object_expires' )
11091108 def test_get_cached_manifest (self , _time_until_object_expires : MagicMock ):
0 commit comments