|
11 | 11 | Vulnerabilities, |
12 | 12 | Vulnerability, |
13 | 13 | audit_poetry_files, |
| 14 | + get_vulnerabilities, |
| 15 | + get_vulnerabilities_from_latest_tag, |
14 | 16 | ) |
| 17 | +from noxconfig import PROJECT_CONFIG |
15 | 18 |
|
16 | 19 |
|
17 | 20 | @pytest.fixture |
@@ -133,3 +136,40 @@ def test_security_issue_dict(sample_vulnerability): |
133 | 136 | ) |
134 | 137 | result = vulnerabilities.security_issue_dict |
135 | 138 | assert result == [sample_vulnerability.security_issue_entry] |
| 139 | + |
| 140 | + |
| 141 | +def test_get_vulnerabilities(sample_vulnerability): |
| 142 | + with mock.patch( |
| 143 | + "exasol.toolbox.util.dependencies.audit.audit_poetry_files", |
| 144 | + return_value=sample_vulnerability.pip_audit_json, |
| 145 | + ): |
| 146 | + result = get_vulnerabilities(PROJECT_CONFIG.root) |
| 147 | + # if successful, no errors & should be non-empty due to mock |
| 148 | + assert isinstance(result, list) |
| 149 | + assert len(result) == 1 |
| 150 | + |
| 151 | + |
| 152 | +class TestGetVulnerabilities: |
| 153 | + def test_with_mock(self, sample_vulnerability): |
| 154 | + with mock.patch( |
| 155 | + "exasol.toolbox.util.dependencies.audit.audit_poetry_files", |
| 156 | + return_value=sample_vulnerability.pip_audit_json, |
| 157 | + ): |
| 158 | + result = get_vulnerabilities(PROJECT_CONFIG.root) |
| 159 | + |
| 160 | + # if successful, no errors & should be 1 due to mock |
| 161 | + assert isinstance(result, list) |
| 162 | + assert len(result) == 1 |
| 163 | + |
| 164 | + |
| 165 | +class TestGetVulnerabilitiesFromLatestTag: |
| 166 | + def test_with_mock(self, sample_vulnerability): |
| 167 | + with mock.patch( |
| 168 | + "exasol.toolbox.util.dependencies.audit.audit_poetry_files", |
| 169 | + return_value=sample_vulnerability.pip_audit_json, |
| 170 | + ): |
| 171 | + result = get_vulnerabilities_from_latest_tag() |
| 172 | + |
| 173 | + # if successful, no errors & should be 1 due to mock |
| 174 | + assert isinstance(result, list) |
| 175 | + assert len(result) == 1 |
0 commit comments