Skip to content

Commit

Permalink
Add support for "OPTIONS" HTTP verb in predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Shkredov authored and brunns committed Jul 26, 2024
1 parent 628a406 commit b1e5a0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mbtest/imposters/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Method(Enum):
POST = "POST"
PUT = "PUT"
PATCH = "PATCH"
OPTIONS = "OPTIONS"

class Operator(Enum):
"""`Predicate operator <http://www.mbtest.org/docs/api/predicates>`_."""
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/test_predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_methods(mock_server):
Stub(Predicate(method=Predicate.Method.POST), Response(body="post")),
Stub(Predicate(method=Predicate.Method.DELETE), Response(body="delete")),
Stub(Predicate(method=Predicate.Method.PATCH), Response(body="patch")),
Stub(Predicate(method=Predicate.Method.OPTIONS), Response(body="options")),
Stub(Predicate(method=Predicate.Method.HEAD), Response(status_code=789)),
]
)
Expand All @@ -119,6 +120,7 @@ def test_methods(mock_server):
put = requests.put(imposter.url)
patch = requests.patch(imposter.url)
get = requests.get(imposter.url)
options = requests.options(imposter.url)
head = requests.head(imposter.url)

# Then
Expand All @@ -127,6 +129,7 @@ def test_methods(mock_server):
assert_that(put, is_response().with_body("put"))
assert_that(patch, is_response().with_body("patch"))
assert_that(get, is_response().with_body("get"))
assert_that(options, is_response().with_body("options"))
assert_that(head, is_response().with_status_code(789))


Expand Down

0 comments on commit b1e5a0e

Please sign in to comment.