示例#1
0
 def test_transfer_delivery_no_recipient(self, mock_azure_transfer):
     mock_azure_transfer.return_value.email_sender.return_value.email_text = "emailtext1"
     mock_azure_transfer.return_value.email_recipient.return_value.email_text = "emailtext2"
     TransferFunctions.transfer_delivery(delivery_id='123', transfer_project=False, add_download_users=False,
                                         change_owner=False, email_sender=False, email_recipient=False)
     tasks.run_next_task()
     expected_calls = [
         call.ensure_transferring_state(),
         call.mark_complete()
     ]
     mock_azure_transfer.return_value.assert_has_calls(expected_calls)
示例#2
0
 def test_restart_transfer_bad_state(self, mock_print, mock_transfer_delivery):
     delivery = AzDelivery.objects.create(
         source_project=AzContainerPath.objects.create(
             path="user1/mouse",
             container_url="http://127.0.0.1"),
         from_netid='user1',
         destination_project=AzContainerPath.objects.create(
             path="user2/mouse",
             container_url="http://127.0.0.1"
         ),
         to_netid='user2',
         share_user_ids=['user3', 'user4'],
     )
     TransferFunctions.restart_transfer(delivery.id)
     mock_print.assert_called_with('Delivery {} is not in transferring state.'.format(delivery.id))
示例#3
0
 def test_transfer_delivery(self, mock_azure_transfer):
     mock_azure_transfer.return_value.email_sender.return_value.email_text = "emailtext1"
     mock_azure_transfer.return_value.email_recipient.return_value.email_text = "emailtext2"
     TransferFunctions.transfer_delivery(delivery_id='123')
     tasks.run_next_task()
     expected_calls = [
         call.ensure_transferring_state(),
         call.record_object_manifest(),
         call.transfer_project(),
         call.give_download_users_permissions(),
         call.update_owner_permissions(),
         call.email_sender(),
         call.email_recipient(),
         call.mark_complete()
     ]
     mock_azure_transfer.return_value.assert_has_calls(expected_calls)
示例#4
0
 def test_restart_transfer_bad_state(self, mock_print, mock_transfer_delivery):
     delivery = AzDelivery.objects.create(
         source_project=AzContainerPath.objects.create(
             path="user1/mouse",
             container_url="http://127.0.0.1"),
         from_netid='user1',
         destination_project=AzContainerPath.objects.create(
             path="user2/mouse",
             container_url="http://127.0.0.1"
         ),
         to_netid='user2',
         share_user_ids=['user3', 'user4'],
         state=State.TRANSFERRING,
     )
     state_to_expected_params = [
         # transfer state       transfer_project, add_download_users, change_owner
         (AzTransferStates.NEW, True, True, True, True, True),
         (AzTransferStates.CREATED_MANIFEST, True, True, True, True, True),
         (AzTransferStates.TRANSFERRED_PROJECT, False, True, True, True, True),
         (AzTransferStates.ADDED_DOWNLOAD_USERS, False, False, True, True, True),
         (AzTransferStates.CHANGED_OWNER, False, False, False, True, True),
         (AzTransferStates.EMAILED_SENDER, False, False, False, False, True),
         (AzTransferStates.EMAILED_RECIPIENT, False, False, False, False, False)
     ]
     for transfer_state, transfer_project, add_download_users, change_owner, email_sender, email_recipient in\
             state_to_expected_params:
         delivery.transfer_state = transfer_state
         delivery.save()
         mock_transfer_delivery.reset()
         TransferFunctions.restart_transfer(delivery.id)
         mock_transfer_delivery.assert_called_with(
             delivery.id,
             transfer_project=transfer_project,
             add_download_users=add_download_users,
             change_owner=change_owner,
             email_sender=email_sender,
             email_recipient=email_recipient)
示例#5
0
def restart_transfer(modeladmin, request, queryset):
    for delivery in queryset:
        TransferFunctions.restart_transfer(delivery.id)