|
2 | 2 |
|
3 | 3 | import logging |
4 | 4 | import os |
5 | | -from testcontainers.compose import DockerCompose |
6 | 5 |
|
7 | 6 | from pact import Verifier |
8 | 7 | import pytest |
|
21 | 20 | PACT_BROKER_PASSWORD = "pactbroker" |
22 | 21 |
|
23 | 22 | PACT_MOCK_HOST = 'localhost' |
24 | | -PACT_MOCK_PORT = 1235 |
| 23 | +PACT_MOCK_PORT = 5001 |
25 | 24 | PACT_URL = "http://{}:{}".format(PACT_MOCK_HOST, PACT_MOCK_PORT) |
26 | 25 | PACT_DIR = os.path.dirname(os.path.realpath(__file__)) |
27 | 26 |
|
| 27 | +@pytest.fixture |
| 28 | +def default_opts(): |
| 29 | + return { |
| 30 | + 'broker_username': PACT_BROKER_USERNAME, |
| 31 | + 'broker_password': PACT_BROKER_PASSWORD, |
| 32 | + 'broker_url': PACT_BROKER_URL |
| 33 | + } |
28 | 34 |
|
29 | | -def test_get_user_non_admin(): |
| 35 | + |
| 36 | +def test_get_user_non_admin(default_opts): |
30 | 37 | verifier = Verifier(provider='UserService', |
31 | 38 | provider_base_url=PACT_URL) |
32 | 39 |
|
33 | | - output, logs = verifier.verify_pacts('./userserviceclient-userservice.json', |
34 | | - verbose=False, |
35 | | - provider_states_setup_url="{}/_pact/provider_states".format(PACT_URL)) |
| 40 | + output, logs = verifier.verify_with_broker(**default_opts, |
| 41 | + verbose=True, |
| 42 | + provider_states_setup_url="{}/_pact/provider_states".format(PACT_URL)) |
36 | 43 |
|
37 | 44 | assert (output == 0) |
38 | | - |
39 | | - |
40 | | -# @pytest.fixture(scope='session') |
41 | | -# def broker(): |
42 | | -# print('Starting broker') |
43 | | -# with DockerCompose("../broker", |
44 | | -# compose_file_name=["docker-compose.yml"], |
45 | | -# pull=True) as compose: |
46 | | - |
47 | | -# stdout, stderr = compose.get_logs() |
48 | | -# if stderr: |
49 | | -# print("Errors\\n:{}".format(stderr)) |
50 | | -# print(stdout) |
51 | | -# yield |
0 commit comments