Skip to content

Commit 0914688

Browse files
committed
fix: Wrap stream passed to reader in C2paStream, add check to tests for validation_status
1 parent ed7f839 commit 0914688

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

c2pa/c2pa_api/c2pa_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Reader(api.Reader):
3838
def __init__(self, format, stream, manifest_data=None):
3939
super().__init__()
4040
if manifest_data is not None:
41-
self.from_manifest_data_and_stream(manifest_data, format, stream)
41+
self.from_manifest_data_and_stream(manifest_data, format, C2paStream(stream))
4242
else:
4343
self.from_stream(format, C2paStream(stream))
4444

tests/test_unit_tests.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,23 @@ def test_streams_sign(self):
9898
builder.sign(TestBuilder.signer, "image/jpeg", file, output)
9999
output.seek(0)
100100
reader = Reader("image/jpeg", output)
101-
self.assertIn("Python Test", reader.json())
101+
json_data = reader.json()
102+
self.assertIn("Python Test", json_data)
103+
self.assertNotIn("validation_status", json_data)
102104

103105
def test_archive_sign(self):
104106
with open(testPath, "rb") as file:
105107
builder = Builder(TestBuilder.manifestDefinition)
106-
archive = byte_array = io.BytesIO(bytearray())
108+
archive = io.BytesIO(bytearray())
107109
builder.to_archive(archive)
108110
builder = Builder.from_archive(archive)
109-
output = byte_array = io.BytesIO(bytearray())
111+
output = io.BytesIO(bytearray())
110112
builder.sign(TestBuilder.signer, "image/jpeg", file, output)
111113
output.seek(0)
112114
reader = Reader("image/jpeg", output)
113-
self.assertIn("Python Test", reader.json())
115+
json_data = reader.json()
116+
self.assertIn("Python Test", json_data)
117+
self.assertNotIn("validation_status", json_data)
114118

115119
def test_remote_sign(self):
116120
with open(testPath, "rb") as file:
@@ -120,7 +124,9 @@ def test_remote_sign(self):
120124
manifest_data = builder.sign(TestBuilder.signer, "image/jpeg", file, output)
121125
output.seek(0)
122126
reader = Reader("image/jpeg", output, manifest_data)
123-
self.assertIn("Python Test", reader.json())
127+
json_data = reader.json()
128+
self.assertIn("Python Test", json_data)
129+
self.assertNotIn("validation_status", json_data)
124130

125131
if __name__ == '__main__':
126-
unittest.main()
132+
unittest.main()

0 commit comments

Comments
 (0)