Exemplo n.º 1
0
def test_broker_config_url(monkeypatch, url, used_url, auth):
    monkeypatch.setattr(Navigator, 'hal', Mock())
    PactBrokerConfig(url).get_broker_navigator()
    Navigator.hal.assert_called_once_with(used_url,
                                          auth=auth,
                                          default_curie='pb',
                                          headers=None)
Exemplo n.º 2
0
def test_broker_config_uses_auth_env(monkeypatch):
    monkeypatch.setenv('PACT_BROKER_AUTH', 'user:pass')
    monkeypatch.setattr(Navigator, 'hal', Mock())
    PactBrokerConfig('http://some.example/').get_broker_navigator()
    Navigator.hal.assert_called_once_with('http://some.example/',
                                          auth=('user', 'pass'),
                                          default_curie='pb',
                                          headers=None)
Exemplo n.º 3
0
def test_broker_config_uses_auth_env(monkeypatch):
    monkeypatch.setenv("PACT_BROKER_AUTH", "user:pass")
    monkeypatch.setattr(Navigator, "hal", Mock())
    PactBrokerConfig("http://some.example/").get_broker_navigator()
    Navigator.hal.assert_called_once_with("http://some.example/",
                                          auth=("user", "pass"),
                                          default_curie="pb",
                                          headers=None)
Exemplo n.º 4
0
def test_broker_config_uses_token_env(monkeypatch):
    monkeypatch.setenv('PACT_BROKER_TOKEN', 'token')
    monkeypatch.setattr(Navigator, 'hal', Mock())
    PactBrokerConfig('http://some.example/').get_broker_navigator()
    Navigator.hal.assert_called_once_with(
        'http://some.example/',
        auth=None,
        default_curie='pb',
        headers=dict(Authorization='Bearer token'))
Exemplo n.º 5
0
def test_broker_config_uses_token_env(monkeypatch):
    monkeypatch.setenv("PACT_BROKER_TOKEN", "token")
    monkeypatch.setattr(Navigator, "hal", Mock())
    PactBrokerConfig("http://some.example/").get_broker_navigator()
    Navigator.hal.assert_called_once_with(
        "http://some.example/",
        auth=None,
        default_curie="pb",
        headers=dict(Authorization="Bearer token"),
    )
Exemplo n.º 6
0
def test_pact_loading(monkeypatch, fake_pact):
    p = BrokerPacts('SpamProvider', PactBrokerConfig('http://broker.example/'))
    mock_pact = Mock(fetch=Mock(return_value=fake_pact))
    mock_provider = Mock(fetch=lambda: None,
                         __getitem__=lambda s, k: [mock_pact])
    monkeypatch.setattr(
        Navigator,
        'hal',
        lambda url, default_curie=None, auth=None, headers=None:
        {'latest-provider-pacts': lambda provider=None: mock_provider})

    for e in p.consumers():
        assert str(
            e
        ) == 'Pact between consumer SpamConsumer and provider SpamProvider'
        assert e.provider == 'SpamProvider'

    for e in p.all_interactions():
        assert e.description == 'dummy'