Skip to content

Commit

Permalink
fix: adjust torii pytests
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara committed Jun 20, 2024
1 parent c953ef1 commit 7b94c95
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
41 changes: 38 additions & 3 deletions torii/pytests/test/configuration/test_post_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,49 @@ def setup_configuration():


@allure.id("1552")
@allure.label("status_code", "400")
@allure.label("status_code", "422")
def test_post_configuration_invalid_data():
with allure.step("WHEN I send POST request with invalid data to /configuration"):
with allure.step(
"WHEN I send POST request with valid json with invalid data to /configuration"
):
response = requests.post(
f"{BASE_URL}/configuration",
json={"logger": {"level": "invalid"}},
)

with allure.step("THEN the response status code should be a client error"):
assert (
422 == response.status_code
), "Response status code is not a client or server error for invalid data"


@allure.id("1553")
@allure.label("status_code", "415")
def test_post_configuration_no_header():
with allure.step(
"WHEN I send POST request without content type json header to /configuration"
):
response = requests.post(
f"{BASE_URL}/configuration",
data=json.dumps({"logger": {"level": "invalid"}}),
)

with allure.step("THEN the response status code should be a client error"):
assert (
415 == response.status_code
), "Response status code is not a client or server error for invalid data"


@allure.id("1554")
@allure.label("status_code", "400")
def test_post_configuration_invalid_json():
with allure.step("WHEN I send POST request with invalid json to /configuration"):
response = requests.post(
f"{BASE_URL}/configuration",
data="i'm not json",
headers={"Content-type": "application/json"},
)

with allure.step("THEN the response status code should be a client error"):
assert (
400 == response.status_code
Expand All @@ -39,7 +74,7 @@ def test_post_configuration_valid_logger_level(log_level):
):
requests.post(
f"{BASE_URL}/configuration",
data=json.dumps({"logger": {"level": log_level}}),
json={"logger": {"level": log_level}},
)

with allure.step(f"THEN the log level should be {log_level}"):
Expand Down
2 changes: 1 addition & 1 deletion torii/pytests/test/general/test_200_status_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_post_configuration_logger_level(log_level):
):
response = requests.post(
f"{BASE_URL}/configuration",
data=json.dumps({"logger": {"level": log_level}}),
json={"logger": {"level": log_level}},
)

with allure.step("THEN the response should be accepted"):
Expand Down
14 changes: 7 additions & 7 deletions torii/pytests/test/general/test_400_status_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def status_codes_400():

@allure.id("1255")
@allure.label("method", "GET")
@allure.label("status_code", "405")
def test_method_not_allowed():
with allure.step("WHEN I send GET request to /method_not_allowed"):
response = requests.get(f"{BASE_URL}/method_not_allowed")
with allure.step("THEN the response status code should be 405"):
@allure.label("status_code", "404")
def test_method_not_found():
with allure.step("WHEN I send GET request to /method_not_found"):
response = requests.get(f"{BASE_URL}/method_not_found")
with allure.step("THEN the response status code should be 404"):
assert (
response.status_code == 405
), "Status code is not 405 for /method_not_allowed"
response.status_code == 404
), "Status code is not 404 for /method_not_found"


@allure.id("1288")
Expand Down

0 comments on commit 7b94c95

Please sign in to comment.