Skip to content

Commit

Permalink
chore: correct import for Verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Aug 15, 2023
1 parent f2a1ce9 commit 3c230e0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion examples/v4/grpc/test_grpc_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
26 changes: 2 additions & 24 deletions pact/ffi/verifier.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand Down
3 changes: 1 addition & 2 deletions pact/message_provider_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion pact/verifier_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
3 changes: 2 additions & 1 deletion tests/ffi/cli/test_verify.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tests/ffi/test_v3_verifier.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion tests/ffi/test_verifier.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 3c230e0

Please sign in to comment.