|
36 | 36 | SynapseFileNotFoundError, |
37 | 37 | SynapseHTTPError, |
38 | 38 | SynapseMd5MismatchError, |
39 | | - SynapseProvenanceError, |
40 | 39 | SynapseUnmetAccessRestrictions, |
41 | 40 | ) |
42 | 41 | from synapseclient.core.logging_setup import DEFAULT_LOGGER_NAME, DEBUG_LOGGER_NAME, SILENT_LOGGER_NAME |
@@ -2445,82 +2444,6 @@ def test_store__existing_no_update(syn): |
2445 | 2444 | assert not mock_updatentity.called |
2446 | 2445 |
|
2447 | 2446 |
|
2448 | | -def test_store_self_stored_obj__provenance_applied(syn): |
2449 | | - """Verify that any object with its own _synapse_store mechanism (e.g. a table) will have |
2450 | | - any passed provenance applied""" |
2451 | | - |
2452 | | - obj = Mock() |
2453 | | - del obj._before_synapse_store |
2454 | | - obj._synapse_store = lambda x: x |
2455 | | - |
2456 | | - activity_kwargs = { |
2457 | | - 'activity': MagicMock(spec=synapseclient.Activity), |
2458 | | - 'activityName': 'test name', |
2459 | | - 'activityDescription': 'test description', |
2460 | | - 'used': ['syn123'], |
2461 | | - 'executed': ['syn456'], |
2462 | | - } |
2463 | | - |
2464 | | - with patch.object(syn, '_apply_provenance') as mock_apply_provenance: |
2465 | | - stored = syn.store(obj, **activity_kwargs) |
2466 | | - assert mock_apply_provenance.called_once_with(obj, **activity_kwargs) |
2467 | | - assert stored == mock_apply_provenance.return_value |
2468 | | - |
2469 | | - |
2470 | | -def test_apply_provenance__duplicate_args(syn): |
2471 | | - """Verify that a SynapseProvenanceError is raised if both used/executed and an Activity is passed""" |
2472 | | - with pytest.raises(SynapseProvenanceError): |
2473 | | - syn._apply_provenance( |
2474 | | - Mock(), |
2475 | | - activity=MagicMock(spec=synapseclient.Activity), |
2476 | | - used=['syn123'], |
2477 | | - executed=['syn456'], |
2478 | | - activityName='test name', |
2479 | | - activityDescription='test description', |
2480 | | - ) |
2481 | | - |
2482 | | - |
2483 | | -def test_apply_provenance__activity(syn): |
2484 | | - """Verify _apply_provenance behavior when an Activity is passed""" |
2485 | | - |
2486 | | - obj = Mock() |
2487 | | - activity = synapseclient.Activity(used=['syn123']) |
2488 | | - with patch.object(syn, 'setProvenance') as mock_set_provenance, \ |
2489 | | - patch.object(syn, '_getEntity') as mock_get_entity: |
2490 | | - result = syn._apply_provenance(obj, activity=activity) |
2491 | | - |
2492 | | - mock_set_provenance.assert_called_once_with(obj, activity) |
2493 | | - mock_get_entity.assert_called_once_with(obj) |
2494 | | - assert result is mock_get_entity.return_value |
2495 | | - |
2496 | | - |
2497 | | -def test_apply_provenance__used_executed(syn): |
2498 | | - """Verify _apply_provenance behavior with used and executed args""" |
2499 | | - |
2500 | | - obj = Mock() |
2501 | | - |
2502 | | - used = ['syn123'] |
2503 | | - executed = ['syn456'] |
2504 | | - name = 'test name' |
2505 | | - description = 'test description' |
2506 | | - |
2507 | | - expected_activity = synapseclient.Activity(used=used, executed=executed, name=name, description=description) |
2508 | | - |
2509 | | - with patch.object(syn, 'setProvenance') as mock_set_provenance, \ |
2510 | | - patch.object(syn, '_getEntity') as mock_get_entity: |
2511 | | - result = syn._apply_provenance( |
2512 | | - obj, |
2513 | | - used=used, |
2514 | | - executed=executed, |
2515 | | - activityName=name, |
2516 | | - activityDescription=description |
2517 | | - ) |
2518 | | - |
2519 | | - mock_set_provenance.assert_called_once_with(obj, expected_activity) |
2520 | | - mock_get_entity.assert_called_once_with(obj) |
2521 | | - assert result is mock_get_entity.return_value |
2522 | | - |
2523 | | - |
2524 | 2447 | def test_get_submission_with_annotations(syn): |
2525 | 2448 | """Verify a getSubmission with annotation entityBundleJSON that |
2526 | 2449 | uses the old style annotations is converted to bundle v2 style |
|
0 commit comments