@@ -64,7 +64,7 @@ def test_stream_read(self):
6464 json_data = reader .json ()
6565 self .assertIn (DEFAULT_TEST_FILE_NAME , json_data )
6666
67- def test_stream_read_get_active_manifest (self ):
67+ def test_get_active_manifest (self ):
6868 with open (self .testPath , "rb" ) as file :
6969 reader = Reader ("image/jpeg" , file )
7070 active_manifest = reader .get_active_manifest ()
@@ -73,6 +73,47 @@ def test_stream_read_get_active_manifest(self):
7373 expected_label = "contentauth:urn:uuid:c85a2b90-f1a0-4aa4-b17f-f938b475804e"
7474 self .assertEqual (active_manifest ["label" ], expected_label )
7575
76+ def test_get_manifest_by_label (self ):
77+ with open (self .testPath , "rb" ) as file :
78+ reader = Reader ("image/jpeg" , file )
79+
80+ # Test getting manifest by the specific label
81+ label = "contentauth:urn:uuid:c85a2b90-f1a0-4aa4-b17f-f938b475804e"
82+ manifest = reader .get_manifest_by_label (label )
83+
84+ # Check that we got the correct manifest
85+ self .assertEqual (manifest ["label" ], label )
86+
87+ # Verify it's the same as the active manifest (since there's only one)
88+ active_manifest = reader .get_active_manifest ()
89+ self .assertEqual (manifest , active_manifest )
90+
91+ def test_stream_get_non_active_manifest_by_label (self ):
92+ video_path = os .path .join (FIXTURES_DIR , "video1.mp4" )
93+ with open (video_path , "rb" ) as file :
94+ reader = Reader ("video/mp4" , file )
95+
96+ non_active_label = "urn:uuid:54281c07-ad34-430e-bea5-112a18facf0b"
97+ non_active_manifest = reader .get_manifest_by_label (non_active_label )
98+
99+ # Check that we got the correct manifest
100+ self .assertEqual (non_active_manifest ["label" ], non_active_label )
101+
102+ # Verify it's not the active manifest
103+ active_manifest = reader .get_active_manifest ()
104+ self .assertNotEqual (non_active_manifest , active_manifest )
105+ self .assertNotEqual (non_active_manifest ["label" ], active_manifest ["label" ])
106+
107+ def test_stream_get_non_active_manifest_by_label_not_found (self ):
108+ video_path = os .path .join (FIXTURES_DIR , "video1.mp4" )
109+ with open (video_path , "rb" ) as file :
110+ reader = Reader ("video/mp4" , file )
111+
112+ # Try to get a manifest with a label that clearly doesn't exist
113+ non_existing_label = "urn:uuid:clearly-not-existing"
114+ with self .assertRaises (KeyError ):
115+ reader .get_manifest_by_label (non_existing_label )
116+
76117 def test_stream_read_get_validation_state (self ):
77118 with open (self .testPath , "rb" ) as file :
78119 reader = Reader ("image/jpeg" , file )
0 commit comments