Skip to content
Snippets Groups Projects
Commit 1b7948ee authored by Frederik Simonsen's avatar Frederik Simonsen
Browse files

start automated testing

parent f368bd09
No related branches found
No related tags found
No related merge requests found
import unittest
from urllib import response
import requests
class Test_API(unittest.TestCase):
GET_API_URL = "http://127.0.0.1:5000/get_models_info"
GET_NAME_API_URL = "http://127.0.0.1:5000/get_model_info"
GET_NAME_API_TEST_JSON_CORRECT = {
"name" : "Active Skin"
}
GET_NAME_API_TEST_JSON_INCORRECT = {
"name" : "Bluefish"
}
GET_NAME_API_TEST_JSON_CORRECT_OUTPUT=[["Active Skin","Classic","Designed for easy handling and solid performance in all conditions, the Madshus Active Skin features a mohair and nylon skin to provide consistent, reliable grip and good glide-all without the need for kick wax or klister!, and the Redline 3.0 classic ski","0","https://i1.adis.ws/i/madshus/madshus_2122_N21344_Active-Skin_A-1?w=412&fmt=webp&fmt.interlaced=true&bg=white&dpi=96","3100","null","null","1","182","Thu, 01 Jan 2015 00:00:00 GMT","Active Skin"]]
def test_1_check_get_api(self):
response = requests.get(Test_API.GET_API_URL)
self.assertEqual(response.headers["Content-Type"],"application/json")
self.assertEqual(response.status_code,200)
def test_2_check_name_api_correct_input_api(self):
response = requests.get(Test_API.GET_NAME_API_URL,json=Test_API.GET_NAME_API_TEST_JSON_CORRECT)
self.assertEqual(response.headers["Content-Type"],"application/json")
self.assertEqual(response.status_code,200)
#self.assertEqual(response.json(),Test_API.GET_NAME_API_TEST_JSON_CORRECT_OUTPUT)
def test_3_check_name_api_incorrect_input_api(self):
response = requests.get(Test_API.GET_NAME_API_URL,json=Test_API.GET_NAME_API_TEST_JSON_INCORRECT)
#self.assertEqual(response.headers["Content-Type","application/json"])
self.assertEqual(response.json(), "No skis matching search request")
self.assertEqual(response.status_code,404)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment