Skip to content

Commit 57a9e5e

Browse files
authored
test: mock ThisTool.version for constisten results (#335)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 11a420c commit 57a9e5e

File tree

92 files changed

+91
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+91
-110
lines changed

tests/base.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,10 @@ def assertEqualJsonBom(self, a: str, b: str) -> None:
9696

9797
# Unify timestamps to ensure they will compare
9898
now = datetime.now(tz=timezone.utc)
99-
10099
if 'metadata' in ab.keys():
101100
ab['metadata']['timestamp'] = now.isoformat()
102-
if 'tools' in ab['metadata'].keys():
103-
for tool in ab['metadata']['tools']:
104-
if tool['name'] == cyclonedx_lib_name:
105-
tool['version'] = cyclonedx_lib_version
106-
del tool
107-
108101
if 'metadata' in bb.keys():
109102
bb['metadata']['timestamp'] = now.isoformat()
110-
if 'tools' in bb['metadata'].keys():
111-
for tool in bb['metadata']['tools']:
112-
if tool['name'] == cyclonedx_lib_name:
113-
tool['version'] = cyclonedx_lib_version
114-
del tool
115103

116104
self.assertEqualJson(json.dumps(ab), json.dumps(bb))
117105

@@ -156,19 +144,10 @@ def assertEqualXmlBom(self, a: str, b: str, namespace: str) -> None:
156144
metadata_ts_a = ba.find('./{{{}}}metadata/{{{}}}timestamp'.format(namespace, namespace))
157145
if metadata_ts_a is not None:
158146
metadata_ts_a.text = now.isoformat()
159-
160147
metadata_ts_b = bb.find('./{{{}}}metadata/{{{}}}timestamp'.format(namespace, namespace))
161148
if metadata_ts_b is not None:
162149
metadata_ts_b.text = now.isoformat()
163150

164-
# Align 'this' Tool Version
165-
this_tool = ba.find('.//*/{{{}}}tool[{{{}}}version="VERSION"]'.format(namespace, namespace))
166-
if this_tool is not None:
167-
this_tool.find('./{{{}}}version'.format(namespace)).text = cyclonedx_lib_version
168-
this_tool = bb.find('.//*/{{{}}}tool[{{{}}}version="VERSION"]'.format(namespace, namespace))
169-
if this_tool is not None:
170-
this_tool.find('./{{{}}}version'.format(namespace)).text = cyclonedx_lib_version
171-
172151
self.assertEqualXml(
173152
xml.etree.ElementTree.tostring(ba, 'unicode'),
174153
xml.etree.ElementTree.tostring(bb, 'unicode')

tests/fixtures/json/1.2/bom_dependencies.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
]
1616
},

tests/fixtures/json/1.2/bom_dependencies_component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
],
1616
"component": {

tests/fixtures/json/1.2/bom_external_references.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
]
1616
},

tests/fixtures/json/1.2/bom_issue_275_components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
],
1616
"component": {

tests/fixtures/json/1.2/bom_issue_328_components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
],
1616
"component": {

tests/fixtures/json/1.2/bom_services_complex.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
],
1616
"component": {

tests/fixtures/json/1.2/bom_services_nested.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
],
1616
"component": {

tests/fixtures/json/1.2/bom_services_simple.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
],
1616
"component": {

tests/fixtures/json/1.2/bom_setuptools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"vendor": "CycloneDX",
1212
"name": "cyclonedx-python-lib",
13-
"version": "3.1.2"
13+
"version": "TESTING"
1414
}
1515
]
1616
},

0 commit comments

Comments
 (0)