ability to ping DelBar API
This commit is contained in:
0
tests/api/__init__.py
Normal file
0
tests/api/__init__.py
Normal file
56
tests/api/test_common.py
Normal file
56
tests/api/test_common.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import pytest
|
||||
|
||||
from delta_barth.api import common
|
||||
from delta_barth.errors import UnspecifiedRequestType
|
||||
from delta_barth.types import HttpRequestTypes
|
||||
|
||||
"http://test.com/ "
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
["case", "expect"],
|
||||
[
|
||||
("http://test.com/ ", "http://test.com"),
|
||||
("http://test.com/", "http://test.com"),
|
||||
("http://test.com ", "http://test.com"),
|
||||
("http://test.com// ", "http://test.com"),
|
||||
("http://test.com", "http://test.com"),
|
||||
(" /http://test.com", "http://test.com"),
|
||||
(" //http://test.com", "http://test.com"),
|
||||
("//http://test.com", "http://test.com"),
|
||||
],
|
||||
)
|
||||
def test_strip_url_components(case, expect):
|
||||
res = common._strip_url_components(case)
|
||||
assert res == expect
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
["base", "route", "expect"],
|
||||
[
|
||||
("http://test.com/ ", "ping", "http://test.com/ping"),
|
||||
("http://test.com/", "ping ", "http://test.com/ping"),
|
||||
("http://test.com ", "ping/", "http://test.com/ping"),
|
||||
("http://test.com// ", "ping", "http://test.com/ping"),
|
||||
("http://test.com", "/ping ", "http://test.com/ping"),
|
||||
(" /http://test.com", "/ ping/ ", "http://test.com/ping"),
|
||||
(" //http://test.com", "ping", "http://test.com/ping"),
|
||||
("//http://test.com", "// ping// ", "http://test.com/ping"),
|
||||
],
|
||||
)
|
||||
def test_combine_route(base, route, expect):
|
||||
res = common.combine_route(base, route)
|
||||
assert res == expect
|
||||
|
||||
|
||||
@pytest.mark.api_con_required
|
||||
def test_ping(api_base_url):
|
||||
resp = common.ping(api_base_url, HttpRequestTypes.GET)
|
||||
assert resp.status_code == 204
|
||||
resp = common.ping(api_base_url, HttpRequestTypes.PUT)
|
||||
assert resp.status_code == 204
|
||||
resp = common.ping(api_base_url, HttpRequestTypes.DELETE)
|
||||
assert resp.status_code == 204
|
||||
|
||||
with pytest.raises(UnspecifiedRequestType):
|
||||
resp = common.ping(api_base_url, HttpRequestTypes.POST)
|
||||
Reference in New Issue
Block a user