Beispiel #1
0
def test_should_raise_exception_when_create_bindings_but_500(
        mocker: MagicMock) -> None:
    response = mock_bad_response_with_status(500)
    patch = mocker.patch('requests.post', return_value=response)
    binding = {
        'source': 'one-s',
        'destination': 'one-d',
        'routing_key': 'one-r',
        'destination_type': 'queue',
        'arguments': None
    }
    try:
        create_binding(broker=fake_broker(),
                       vhost='EA',
                       binding=Binding(binding))
    except ServerErrorException as e:
        assert_that(e.url).is_equal_to(
            'https://fake-broker/api/bindings/EA/e/one-s/q/one-d')
    patch.assert_called_with(
        url='https://fake-broker/api/bindings/EA/e/one-s/q/one-d',
        auth=('guest', 'guest'),
        json={
            'routing_key': 'one-r',
            'arguments': None
        })
Beispiel #2
0
def test_should_create_bindings(mocker: MagicMock) -> None:
    response = mock_response([])
    patch = mocker.patch('requests.post', return_value=response)
    binding = {
        'source': 'one-s',
        'destination': 'one-d',
        'routing_key': 'one-r',
        'destination_type': 'queue',
        'arguments': None
    }
    create_binding(broker=fake_broker(), vhost='EA', binding=Binding(binding))
    patch.assert_called_with(
        url='https://fake-broker/api/bindings/EA/e/one-s/q/one-d',
        auth=('guest', 'guest'),
        json={
            'routing_key': 'one-r',
            'arguments': None
        })