|
20 | 20 | import os |
21 | 21 | from unittest import TestCase |
22 | 22 |
|
| 23 | +from cyclonedx.model import HashAlgorithm, HashType |
| 24 | +from cyclonedx.model.component import Component |
| 25 | + |
23 | 26 | from cyclonedx_py.parser.requirements import RequirementsFileParser, RequirementsParser |
24 | 27 |
|
25 | 28 |
|
@@ -68,6 +71,11 @@ def test_example_multilines_with_comments(self) -> None: |
68 | 71 |
|
69 | 72 | self.assertFalse(parser.has_warnings(), f'{parser.get_warnings()}') |
70 | 73 | self.assertEqual(1, len(components), f'{components}') |
| 74 | + component: Component = components[0] |
| 75 | + self.assertEqual(1, len(component.hashes)) |
| 76 | + hash: HashType = component.hashes.pop() |
| 77 | + self.assertEqual(HashAlgorithm.SHA_256, hash.alg) |
| 78 | + self.assertNotEqual(0, len(hash.content), f'{hash.content}') |
71 | 79 |
|
72 | 80 | def test_example_local_packages(self) -> None: |
73 | 81 | with open(os.path.join(os.path.dirname(__file__), |
@@ -125,6 +133,14 @@ def test_example_with_hashes(self) -> None: |
125 | 133 | self.assertFalse(parser.has_warnings(), f'{parser.get_warnings()}') |
126 | 134 | self.assertEqual(5, len(components), f'{components}') |
127 | 135 |
|
| 136 | + c_idna = next(filter(lambda c: c.name == 'idna', components), None) |
| 137 | + self.assertIsNotNone(c_idna) |
| 138 | + self.assertEqual('idna', c_idna.name) |
| 139 | + self.assertEqual(2, len(c_idna.hashes), f'{c_idna.hashes}') |
| 140 | + hash: HashType = c_idna.hashes.pop() |
| 141 | + self.assertEqual(HashAlgorithm.SHA_256, hash.alg) |
| 142 | + self.assertNotEqual(0, len(hash.content), f'{hash.content}') |
| 143 | + |
128 | 144 | def test_example_without_pinned_versions_warns(self) -> None: |
129 | 145 | with open(os.path.join(os.path.dirname(__file__), |
130 | 146 | 'fixtures/requirements-without-pinned-versions.txt')) as r: |
|
0 commit comments