-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Endpoint Categorization including method (#39)
* endpoint now includes method * standardize on .lower() --------- Co-authored-by: Steve Bunting <[email protected]>
- Loading branch information
1 parent
b29615b
commit 21c6eef
Showing
6 changed files
with
67 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
import requests | ||
from pytest_httpserver import HTTPServer | ||
|
||
from supergood.api import Api | ||
from tests.helper import get_remote_config | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"supergood_client", | ||
[{"remote_config": get_remote_config(action="Ignore", method="POST")}], | ||
indirect=True, | ||
) | ||
class TestMethod: | ||
def test_method_matching(self, httpserver: HTTPServer, supergood_client): | ||
httpserver.expect_request("/200", "POST").respond_with_json( | ||
{ | ||
"string": "abc", | ||
} | ||
) | ||
httpserver.expect_request("/200", "GET").respond_with_json( | ||
{ | ||
"string": "def", | ||
} | ||
) | ||
response1 = requests.request( | ||
method="post", | ||
url=httpserver.url_for("/200"), | ||
) | ||
# First call is ignored due to matching the ignored POST methods | ||
assert response1.json()["string"] == "abc" | ||
supergood_client.flush_cache() | ||
assert Api.post_events.call_args is None | ||
response2 = requests.request(method="get", url=httpserver.url_for("/200")) | ||
# Second call is cached and flushed because it does not match (i.e. is a new endpoint) | ||
assert response2.json()["string"] == "def" | ||
supergood_client.flush_cache() | ||
args = Api.post_events.call_args[0][0] | ||
assert len(args) == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters