|
17 | 17 | from component_catalog.models import Package |
18 | 18 | from component_catalog.tests import make_package |
19 | 19 | from dejacode_toolkit.scancodeio import ScanCodeIO |
20 | | -from dejacode_toolkit.scancodeio import check_for_existing_scan_workaround |
21 | 20 | from dejacode_toolkit.scancodeio import get_hash_uid |
22 | 21 | from dejacode_toolkit.scancodeio import get_notice_text_from_key_files |
| 22 | +from dejacode_toolkit.scancodeio import update_package_from_existing_scan_data |
23 | 23 | from dje.models import Dataspace |
24 | 24 | from dje.models import History |
25 | 25 | from dje.tasks import scancodeio_submit_scan |
@@ -67,9 +67,7 @@ def test_scancodeio_submit_scan_task(self, mock_submit_scan, mock_request_head): |
67 | 67 |
|
68 | 68 | expected = [ |
69 | 69 | mock.call("http://okurl.com", user_uuid, dataspace_uuid), |
70 | | - mock.call().__bool__(), |
71 | 70 | mock.call("https://okurl2.com", user_uuid, dataspace_uuid), |
72 | | - mock.call().__bool__(), |
73 | 71 | ] |
74 | 72 | self.assertEqual(expected, mock_submit_scan.mock_calls) |
75 | 73 |
|
@@ -334,19 +332,13 @@ def test_scancodeio_get_notice_text_from_key_files(self): |
334 | 332 | self.assertEqual("", notice_text) |
335 | 333 |
|
336 | 334 | @mock.patch("component_catalog.models.Package.update_from_scan") |
337 | | - def test_scancodeio_check_for_existing_scan_workaround(self, mock_update_from_scan): |
| 335 | + def test_scancodeio_update_package_from_existing_scan_data(self, mock_update_from_scan): |
338 | 336 | mock_update_from_scan.return_value = ["updated_field"] |
339 | 337 | download_url = self.package1.download_url |
340 | 338 | user = self.basic_user |
341 | 339 |
|
342 | | - response_json = None |
343 | | - results = check_for_existing_scan_workaround(response_json, download_url, user) |
| 340 | + results = update_package_from_existing_scan_data("unknown_url", user) |
344 | 341 | self.assertIsNone(results) |
345 | 342 |
|
346 | | - response_json = {"success": True} |
347 | | - results = check_for_existing_scan_workaround(response_json, download_url, user) |
348 | | - self.assertIsNone(results) |
349 | | - |
350 | | - response_json = {"name": "project with this name already exists."} |
351 | | - results = check_for_existing_scan_workaround(response_json, download_url, user) |
| 343 | + results = update_package_from_existing_scan_data(download_url, user) |
352 | 344 | self.assertEqual(["updated_field"], results) |
0 commit comments