Beispiel #1
0
def test_should_raise_exception_when_create_exchange_but_500(mocker: MagicMock) -> None:
    response = mock_bad_response_with_status(500)
    patch = mocker.patch('requests.put', return_value=response)
    try:
        create_exchange(broker=fake_broker(), vhost='EA', name='test', exchange={'type': 'direct'})
    except ServerErrorException as e:
        assert_that(e.url).is_equal_to('https://fake-broker/api/exchanges/EA/test')
    patch.assert_called_with(url='https://fake-broker/api/exchanges/EA/test', auth=('guest', 'guest'),
                             json={'type': 'direct'})
Beispiel #2
0
def test_should_create_exchange(mocker: MagicMock) -> None:
    response = mock_response([])
    patch = mocker.patch('requests.put', return_value=response)
    create_exchange(broker=fake_broker(), vhost='EA', name='test', exchange={'type': 'direct'})
    patch.assert_called_with(url='https://fake-broker/api/exchanges/EA/test', auth=('guest', 'guest'),
                             json={'type': 'direct'})