def test_publish_invalid_credentials(monkeypatch: Any, capsys: Any,
                                     loop: Any) -> None:
    services, future = start_service("tests/services/dummy_service.py",
                                     monkeypatch)

    instance = services.get("test_dummy")

    with pytest.raises(AWSSNSSQSException):
        loop.run_until_complete(
            AWSSNSSQSTransport.publish(instance,
                                       "data",
                                       "test-topic",
                                       wait=True))

    async def _async_kill():
        os.kill(os.getpid(), signal.SIGINT)

    loop.create_task(_async_kill())
    loop.run_until_complete(future)

    if not future.done():
        future.set_result(None)

    out, err = capsys.readouterr()
    assert "The security token included in the request is invalid" in err
    assert out == ""
Beispiel #2
0
def test_publish_invalid_credentials(monkeypatch: Any, capsys: Any, loop: Any) -> None:
    services, future = start_service('tests/services/dummy_service.py', monkeypatch)

    instance = services.get('test_dummy')

    with pytest.raises(AWSSNSSQSException):
        loop.run_until_complete(AWSSNSSQSTransport.publish(instance, 'data', 'test-topic', wait=True))

    os.kill(os.getpid(), signal.SIGINT)
    loop.run_until_complete(future)

    out, err = capsys.readouterr()
    assert 'The security token included in the request is invalid' in err
    assert out == ''