test: added api input type checking tests [no ci]

This commit is contained in:
Alec.Schmidt
2025-03-12 21:04:31 +01:00
parent ee2f80d670
commit 34e24304fa

View File

@@ -17,6 +17,7 @@
from urllib.parse import urlencode from urllib.parse import urlencode
import json import json
import pytest
__author__ = 'Michael Mader' __author__ = 'Michael Mader'
__date__ = "2023-03-12" __date__ = "2023-03-12"
@@ -63,3 +64,26 @@ def test_multiply(client):
def test_division(client): def test_division(client):
result = call(client, '/div', {'x': 35, 'y': 7}) result = call(client, '/div', {'x': 35, 'y': 7})
assert result['result'] == 5 assert result['result'] == 5
# type tests
def test_type_inc(client):
result = call(client, '/inc', {'x': 'a'})
assert result["error"] == "Type error"
def test_type_add(client):
result = call(client, '/add', {'x': 'a', 'y': 1})
assert result["error"] == "Type error"
result = call(client, '/add', {'x': 1, 'y': 'a'})
assert result["error"] == "Type error"
def test_type_mul(client):
result = call(client, '/mul', {'x': 'a', 'y': 1})
assert result["error"] == "Type error"
result = call(client, '/mul', {'x': 1, 'y': 'a'})
assert result["error"] == "Type error"
def test_type_div(client):
result = call(client, '/div', {'x': 'a', 'y': 1})
assert result["error"] == "Type error"
result = call(client, '/div', {'x': 1, 'y': 'a'})
assert result["error"] == "Type error"