Skip to content

Commit 95cf481

Browse files
Paul Hewletteccles
authored andcommitted
Tidy up sboms finctional test
Solution: Explicitly show progress of sboms functional test Signed-off-by: Paul Hewlett <phewlett76@gmail.com>
1 parent a2e7fa7 commit 95cf481

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

functests/execsboms.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
from contextlib import suppress
55
from filecmp import clear_cache, cmp
6+
from json import dumps as json_dumps
67
from os import environ, remove
78
from time import sleep
89
from unittest import TestCase
@@ -25,6 +26,8 @@ class TestSBOM(TestCase):
2526
Test Archivist SBOM upload/download
2627
"""
2728

29+
maxDiff = None
30+
2831
TEST_SBOM_PATH = "functests/test_resources/bom.xml"
2932
TEST_SBOM_DOWNLOAD_PATH = "functests/test_resources/downloaded_bom.xml"
3033

@@ -53,16 +56,19 @@ def test_sbom_upload_and_download(self):
5356
with open(self.TEST_SBOM_PATH, "rb") as fd:
5457
metadata = self.arch.sboms.upload(fd)
5558

59+
print("metadata", json_dumps(metadata.dict(), indent=4))
5660
identity = metadata.identity
5761
with open(self.TEST_SBOM_DOWNLOAD_PATH, "wb") as fd:
5862
sbom = self.arch.sboms.download(identity, fd)
5963

64+
print("sbom", sbom)
6065
clear_cache()
6166
self.assertTrue(
6267
cmp(self.TEST_SBOM_PATH, self.TEST_SBOM_DOWNLOAD_PATH, shallow=False)
6368
)
6469

6570
metadata1 = self.arch.sboms.read(identity)
71+
print("metadata1", json_dumps(metadata1.dict(), indent=4))
6672
self.assertEqual(
6773
metadata,
6874
metadata1,
@@ -71,6 +77,9 @@ def test_sbom_upload_and_download(self):
7177

7278
sleep(1) # otherwise test fails
7379
metadatas = list(self.arch.sboms.list(metadata={"uploaded_since": now}))
80+
for i, m in enumerate(metadatas):
81+
print(i, ":", json_dumps(m.dict(), indent=4))
82+
7483
self.assertEqual(
7584
len(metadatas),
7685
1,
@@ -84,12 +93,14 @@ def test_sbom_upload_and_download(self):
8493

8594
sleep(1) # otherwise test fails
8695
metadata2 = self.arch.sboms.publish(identity)
96+
print("metadata2", json_dumps(metadata2.dict(), indent=4))
8797
self.assertNotEqual(
8898
metadata1.published_date,
8999
metadata2.published_date,
90100
msg="Published_date not correct",
91101
)
92102
metadata3 = self.arch.sboms.publish(identity)
103+
print("metadata3", json_dumps(metadata3.dict(), indent=4))
93104
self.assertEqual(
94105
metadata2.published_date,
95106
metadata3.published_date,
@@ -98,6 +109,7 @@ def test_sbom_upload_and_download(self):
98109

99110
sleep(1) # otherwise test fails
100111
metadata4 = self.arch.sboms.withdraw(identity)
112+
print("metadata4", json_dumps(metadata4.dict(), indent=4))
101113
self.assertNotEqual(
102114
metadata3.withdrawn_date,
103115
metadata4.withdrawn_date,
@@ -110,8 +122,22 @@ def test_sbom_upload_and_download(self):
110122
)
111123

112124
metadata5 = self.arch.sboms.withdraw(identity)
125+
print("metadata5", json_dumps(metadata5.dict(), indent=4))
113126
self.assertEqual(
114127
metadata4.withdrawn_date,
115128
metadata5.withdrawn_date,
116129
msg="Withdrawn_date not correct",
117130
)
131+
132+
sleep(1) # otherwise test fails
133+
metadatas = list(
134+
self.arch.sboms.list(
135+
page_size=50,
136+
metadata={
137+
"search": "*",
138+
"privacy": "PUBLIC",
139+
},
140+
)
141+
)
142+
for i, m in enumerate(metadatas):
143+
print(i, ":", json_dumps(m.dict(), indent=4))

0 commit comments

Comments
 (0)