예제 #1
0
def get_mock_customer_logic():
    global customer_logic_mock
    customer_logic_mock = mock.MagicMock()

    if root.CustomerLogic.return_error == 0:
        res = Models.CustomerResultWrapper(transaction_id='1',
                                           id='1',
                                           links={},
                                           updated=None,
                                           created='1')

        list_res = Models.CustomerSummaryResponse()
        list_res.customers.append(Models.CustomerSummary(name='1', id='1', description='1'))

        customer_logic_mock.create_customer.return_value = res
        customer_logic_mock.update_customer.return_value = res
        customer_logic_mock.get_customer.return_value = Models.Customer(**RET_CUSTOMER_JSON)
        customer_logic_mock.get_customer_list_by_criteria.return_value = list_res

    elif root.CustomerLogic.return_error == 1:
        customer_logic_mock.create_customer.side_effect = SystemError()
        customer_logic_mock.update_customer.side_effect = SystemError()
        customer_logic_mock.get_customer.side_effect = SystemError()
        customer_logic_mock.delete_customer_by_uuid.side_effect = SystemError()
        customer_logic_mock.get_customer_list_by_criteria.side_effect = SystemError()

    else:
        customer_logic_mock.create_customer.side_effect = ErrorStatus(status_code=404)
        customer_logic_mock.update_customer.side_effect = ErrorStatus(status_code=404)
        customer_logic_mock.get_customer.side_effect = ErrorStatus(status_code=404)
        customer_logic_mock.delete_customer_by_uuid.side_effect = ErrorStatus(
            status_code=409)
        customer_logic_mock.get_customer_list_by_criteria.side_effect = ErrorStatus(status_code=404)

    return customer_logic_mock
예제 #2
0
def get_mock_customer_logic():
    global metadata_logic_mock
    metadata_logic_mock = mock.MagicMock()

    if metadata.logic.return_error == 0:
        res = Models.CustomerResultWrapper(transaction_id='1',
                                           id='1',
                                           links={},
                                           updated=None,
                                           created='1')

        metadata_logic_mock.add_customer_metadata.return_value = res
        metadata_logic_mock.update_customer_metadata.return_value = res

    elif metadata.logic.return_error == 1:
        metadata_logic_mock.add_customer_metadata.side_effect = SystemError()
        metadata_logic_mock.update_customer_metadata.side_effect = SystemError()

    elif metadata.logic.return_error == 2:
        metadata_logic_mock.add_customer_metadata.side_effect = ErrorStatus(status_code=404)
        metadata_logic_mock.update_customer_metadata.side_effect = ErrorStatus(status_code=404)

    elif metadata.logic.return_error == 3:
        metadata_logic_mock.add_customer_metadata.side_effect = LookupError()
        metadata_logic_mock.update_customer_metadata.side_effect = LookupError()

    elif metadata.logic.return_error == 4:
        metadata_logic_mock.add_customer_metadata.side_effect = AttributeError()
        metadata_logic_mock.update_customer_metadata.side_effect = AttributeError()

    elif metadata.logic.return_error == 5:
        metadata_logic_mock.add_customer_metadata.side_effect = ValueError()
        metadata_logic_mock.update_customer_metadata.side_effect = ValueError()

    return metadata_logic_mock
예제 #3
0
def get_mock_customer_logic():
    global customer_logic_mock
    customer_logic_mock = mock.MagicMock()

    if enabled.CustomerLogic.return_error == 0:
        res = Models.CustomerResultWrapper(transaction_id='1',
                                           id='1',
                                           links={},
                                           updated=None,
                                           created='1')

        customer_logic_mock.enable.return_value = res

    elif enabled.CustomerLogic.return_error == 1:
        customer_logic_mock.enable.side_effect = SystemError()

    elif enabled.CustomerLogic.return_error == 2:
        customer_logic_mock.enable.side_effect = ErrorStatus(status_code=404)

    return customer_logic_mock