From 34e24304fa03fb9ad3a079ba554124a292ca5ad3 Mon Sep 17 00:00:00 2001 From: "Alec.Schmidt" Date: Wed, 12 Mar 2025 21:04:31 +0100 Subject: [PATCH] test: added api input type checking tests [no ci] --- src/tests/test_api.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tests/test_api.py b/src/tests/test_api.py index e172bc7..cceefb7 100644 --- a/src/tests/test_api.py +++ b/src/tests/test_api.py @@ -17,6 +17,7 @@ from urllib.parse import urlencode import json +import pytest __author__ = 'Michael Mader' __date__ = "2023-03-12" @@ -63,3 +64,26 @@ def test_multiply(client): def test_division(client): result = call(client, '/div', {'x': 35, 'y': 7}) 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" \ No newline at end of file