From 3c230e06610f086bfa1c922fbfc3af70ba1e0528 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 15 Aug 2023 18:34:00 +0100 Subject: [PATCH] chore: correct import for Verifier --- examples/v4/grpc/test_grpc_provider.py | 2 +- pact/ffi/verifier.py | 26 ++------------------------ pact/message_provider_v3.py | 3 +-- pact/verifier_v3.py | 24 +++++++++++++++++++++++- tests/ffi/cli/test_verify.py | 3 ++- tests/ffi/test_v3_verifier.py | 2 +- tests/ffi/test_verifier.py | 3 ++- 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/examples/v4/grpc/test_grpc_provider.py b/examples/v4/grpc/test_grpc_provider.py index a6dd510c7..3fe692f78 100644 --- a/examples/v4/grpc/test_grpc_provider.py +++ b/examples/v4/grpc/test_grpc_provider.py @@ -3,7 +3,7 @@ import pytest from pact import VerifierV3 import subprocess -from pact.ffi.verifier import VerifyStatus +from pact.verifier_v3 import VerifyStatus @pytest.mark.skipif( version_info < (3, 7), diff --git a/pact/ffi/verifier.py b/pact/ffi/verifier.py index c603d3923..91c907c9b 100644 --- a/pact/ffi/verifier.py +++ b/pact/ffi/verifier.py @@ -1,31 +1,9 @@ """Wrapper to pact reference dynamic libraries using FFI.""" -from enum import Enum, unique -from typing import Dict, NamedTuple, List +from typing import Dict, List from pact.ffi.pact_ffi import PactFFI import json - - -@unique -class VerifyStatus(Enum): - """Return codes from a verify request. - - As per: https://docs.rs/pact_ffi/0.0.2/pact_ffi/verifier/fn.pactffi_verify.html - """ - - SUCCESS = 0 # Operation succeeded - VERIFIER_FAILED = 1 # The verification process failed, see output for errors - NULL_POINTER = 2 # A null pointer was received - PANIC = 3 # The method panicked - INVALID_ARGS = 4 # Invalid arguments were provided to the verification process - - -class VerifyResult(NamedTuple): - """Wrap up the return code, and log output.""" - - return_code: VerifyStatus - logs: List[str] - +from pact.verifier_v3 import VerifyResult class Argument: """Hold the attributes of a single argument which can be used by the Verifier.""" diff --git a/pact/message_provider_v3.py b/pact/message_provider_v3.py index 5288a2700..c39449afe 100644 --- a/pact/message_provider_v3.py +++ b/pact/message_provider_v3.py @@ -6,8 +6,7 @@ from requests.adapters import HTTPAdapter from urllib3 import Retry from multiprocessing import Process -from pact.ffi.verifier import VerifyResult -from pact.verifier_v3 import VerifierV3 +from pact.verifier_v3 import VerifierV3, VerifyResult from .http_proxy_v3 import run_proxy_v3 import logging diff --git a/pact/verifier_v3.py b/pact/verifier_v3.py index 497cb7b97..35f610f57 100644 --- a/pact/verifier_v3.py +++ b/pact/verifier_v3.py @@ -4,11 +4,33 @@ from typing import NamedTuple from pact.ffi.native_verifier import NativeVerifier from urllib.parse import urlparse -from pact.ffi.verifier import VerifyResult from pact.pact_exception import PactException from pact.verify_wrapper import is_url +from enum import Enum, unique +from typing import Dict, NamedTuple, List + +@unique +class VerifyStatus(Enum): + """Return codes from a verify request. + + As per: https://docs.rs/pact_ffi/0.0.2/pact_ffi/verifier/fn.pactffi_verify.html + """ + + SUCCESS = 0 # Operation succeeded + VERIFIER_FAILED = 1 # The verification process failed, see output for errors + NULL_POINTER = 2 # A null pointer was received + PANIC = 3 # The method panicked + INVALID_ARGS = 4 # Invalid arguments were provided to the verification process + + +class VerifyResult(NamedTuple): + """Wrap up the return code, and log output.""" + + return_code: VerifyStatus + logs: List[str] + class CustomHeader(NamedTuple): """Custom header to send in the Pact Verifier request.""" diff --git a/tests/ffi/cli/test_verify.py b/tests/ffi/cli/test_verify.py index 5ef87ee61..9970e7652 100644 --- a/tests/ffi/cli/test_verify.py +++ b/tests/ffi/cli/test_verify.py @@ -1,5 +1,6 @@ from pact.ffi.cli.verify import main -from pact.ffi.verifier import Verifier, VerifyStatus +from pact.ffi.verifier import Verifier +from pact.verifier_v3 import VerifyStatus def test_cli_args(): diff --git a/tests/ffi/test_v3_verifier.py b/tests/ffi/test_v3_verifier.py index 527ee13c7..d5f446765 100644 --- a/tests/ffi/test_v3_verifier.py +++ b/tests/ffi/test_v3_verifier.py @@ -1,7 +1,7 @@ import pytest from pact import VerifierV3 import platform -from pact.ffi.verifier import VerifyStatus +from pact.verifier_v3 import VerifyStatus from pact.pact_exception import PactException diff --git a/tests/ffi/test_verifier.py b/tests/ffi/test_verifier.py index 16a64fcbd..cf50d0cde 100644 --- a/tests/ffi/test_verifier.py +++ b/tests/ffi/test_verifier.py @@ -1,5 +1,6 @@ -from pact.ffi.verifier import Verifier, VerifyStatus +from pact.ffi.verifier import Verifier +from pact.verifier_v3 import VerifyStatus def test_version(): result = Verifier().version()