Exemplo n.º 1
0
def test_onboard_service_several_resources(mock_create, mock_add_resource,
                                           mock_checkin, mock_submit,
                                           mock_start_certification,
                                           mock_certify, mock_approve,
                                           mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            const.DRAFT, const.DRAFT, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, None
        ]
        resource1 = SdcResource()
        resource2 = SdcResource()
        service = Service(resources=[resource1, resource2])
        service._time_wait = 0
        service.onboard()
        mock_create.assert_not_called()
        calls = [mock.call(resource1), mock.call(resource2)]
        mock_add_resource.assert_has_calls(calls, any_order=True)
        assert mock_add_resource.call_count == 2
        mock_checkin.assert_called_once()
        mock_submit.assert_not_called()
        mock_start_certification.assert_not_called()
        mock_certify.assert_not_called()
        mock_approve.assert_not_called()
        mock_distribute.assert_not_called()
Exemplo n.º 2
0
def test_onboard_service_distribute(mock_create, mock_add_resource,
                                    mock_checkin, mock_certify,
                                    mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            const.CERTIFIED, const.CERTIFIED, const.CERTIFIED, const.CERTIFIED,
            const.CERTIFIED, const.CERTIFIED, const.CERTIFIED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, None
        ]
        service = Service()
        service._time_wait = 0
        service.onboard()
        mock_create.assert_not_called()
        mock_add_resource.assert_not_called()
        mock_checkin.assert_not_called()
        mock_certify.assert_not_called()
        mock_distribute.assert_called_once()
Exemplo n.º 3
0
def test_onboard_whole_service(mock_create, mock_add_resource, mock_checkin,
                               mock_certify, mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            None, const.DRAFT, const.DRAFT, const.CHECKED_IN, const.CHECKED_IN,
            const.CHECKED_IN, const.CERTIFIED, const.CERTIFIED,
            const.CERTIFIED, const.CERTIFIED, const.CERTIFIED, const.CERTIFIED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, None
        ]
        resource = SdcResource()
        service = Service(resources=[resource])
        service._time_wait = 0
        service.onboard()
        mock_create.assert_called_once()
        mock_add_resource.assert_called_once_with(resource)
        mock_checkin.assert_called_once()
        mock_certify.assert_called_once()
        mock_distribute.assert_called_once()
Exemplo n.º 4
0
def test_onboard_service_resources(mock_create, mock_add_resource,
                                   mock_checkin, mock_submit,
                                   mock_start_certification, mock_certify,
                                   mock_approve, mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            const.DRAFT, const.DRAFT, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, None
        ]
        resource = SdcResource()
        service = Service(resources=[resource])
        service._time_wait = 0
        service.onboard()
        mock_create.assert_not_called()
        mock_add_resource.assert_called_once_with(resource)
        mock_checkin.assert_called_once()
        mock_submit.assert_not_called()
        mock_start_certification.assert_not_called()
        mock_certify.assert_not_called()
        mock_approve.assert_not_called()
        mock_distribute.assert_not_called()