def test_get_coaches(): r = requests.get(a.api_link() + "profile/coach") assert r.status_code == 200, r.status_code v = Validator(a.s_coach()) assert v.validate(r.json()[0]['coach']) == True, v.errors v = Validator(a.s_studentData()) assert v.validate(r.json()[0]['user']) == True, v.errors
def test_put_coach_byId(): payload = "{\n\t\"studentID\": 000701,\n\t\"workload\": 5 \n}" headers = {'Content-Type': "application/json", 'cache-control': "no-cache"} r = requests.put(a.api_link() + "coach/" + a.coachId(), data=payload, headers=headers) assert r.status_code == 204, r.text
def test_get_tutorants(): r = requests.get(a.api_link() + "profile/tutorant") assert r.status_code == 200, r.status_code v = Validator(a.s_tutorant()) assert v.validate(r.json()[0]['tutorant']) == True, v.errors v = Validator(a.s_studentData()) assert v.validate(r.json()[0]['user']) == True, v.errors
def test_put_student_byId(): tut = a.tutorantId() url = a.api_link() + "student/" + tut payload = "{\n\"studentID\": " + a.tutorantId( ) + " ,\n \"firstName\": \"TestCoach+1\",\n \"surName\": \"Test\",\n \"phoneNumber\": \"0692495724\",\n \"interests\": \"Programming (C only), Servers, Cisco\",\n \"photo\": \"https://i.imgur.com/Tl5sYD6.jpg\",\n \"description\": \"I am a coach\",\n \"degree\": \"HBO\",\n \"study\": \"Technische Informatica\",\n \"studyYear\": 4\n}" headers = {'Content-Type': "application/json", 'cache-control': "no-cache"} r = requests.put(url, data=payload, headers=headers) assert r.status_code == 204, r.status_code
def test_put_coachTutorant_tutorant_byId(): tut = a.tutorantId() url = a.api_link() + "coachTutorant" payload = "{\n\"studentIDTutorant\":\""+ tut +"\",\n\"studentIDCoach\": \""+ a.coachId() +"\",\n\"status\":\"Completed\"\n}" headers = { 'Content-Type': "application/json", 'cache-control': "no-cache"} r = requests.put(url, data=payload, headers=headers) assert r.status_code == 204, r.status_code
def test_post_tutorant(): a.delete_tutorant(a.tutorantId()) url = a.api_link() + "profile/tutorant" payload = "{\n \"user\": {\n \"studentID\": \"" + a.tutorantId( ) + "\",\n \"firstName\": \"TestTutorant\",\n \"surName\": \"Test\",\n \"phoneNumber\": \"0692495724\",\n \"interests\": \"Programming (C only), Servers, Cisco\",\n \"photo\": \"https://i.imgur.com/Tl5sYD6.jpg\",\n \"description\": \"I am a student\",\n \"degree\": \"HBO\",\n \"study\": \"Technische Informatica\",\n \"studyYear\": 4\n }, \n \"tutorant\": {\n \"studentID\": \"" + a.tutorantId( ) + "\"\n } \n}" headers = {'Content-Type': "application/json", 'cache-control': "no-cache"} r = requests.request("POST", url, data=payload, headers=headers) if r.status_code is not 201: a.create_tutorant(a.tutorantId()) assert r.status_code == 201, r.status_code
def test_post_coachTutorant(): tut = a.tutorantId() a.delete_coachTutorant(tut) url = a.api_link() + "coachTutorant/tutorant/" + tut payload = "{\n\"studentIDTutorant\":\""+ tut +"\",\n\"studentIDCoach\": \""+ a.coachId() +"\",\n\"status\":\"Pending\"\n}" headers = { 'Content-Type': "application/json", 'cache-control': "no-cache"} r = requests.post(url, data=payload, headers=headers) if r.status_code is not 201: a.create_coachTutorant(tut) assert r.status_code == 201, r.status_code
def test_post_coach(): a.delete_multiple_coachTutorant a.delete_multiple_tutorant a.delete_coach() url = a.api_link() + "profile/coach" payload = "{\n\"coach\": {\n \"studentID\": \"" + a.coachId( ) + "\",\n \"workload\": 5\n },\n \"user\": {\n \"studentID\": \"" + a.coachId( ) + "\",\n \"firstName\": \"TestCoach\",\n \"surName\": \"Test\"}}" headers = {'Content-Type': "application/json", 'cache-control': "no-cache"} r = requests.post(url, data=payload, headers=headers) if r.status_code is not 201: a.create_coach() a.create_multiple_tutorant a.create_multiple_coachTutorant assert r.status_code == 201, r.status_code a.create_multiple_tutorant a.create_multiple_coachTutorant
def test_get_student(): print("test_get_student") r = requests.get(a.api_link() + "students/search?studentId=" + a.studentId()) assert r.status_code == 200, r.status_code
def test_put_student(): print("test_put_student") r = requests.get(a.api_link() + "student/" + a.studentId()) assert r.status_code == 200, r.status_code
def test_post_message(): payload = "{\n\t\"type\": \"text\",\n\t\"payload\": \"Hi Barend ;)\",\n\t\"created\": \"2019-11-1\",\n\t\"lastModified\": \"2019-11-1\",\n\t\"senderID\": \"701\",\n\t\"receiverID\": \"710\"\n}" headers = {'Content-Type': "application/json", 'cache-control': "no-cache"} r = requests.post(a.api_link() + "message/", payload, headers) assert r.status_code == 201, r.status_code
def test_get_messages_coachId_tutorantId(): params = {"amountOfMessages": 20} r = requests.get(a.api_link() + "messages/" + a.coachId() + "/" + a.tutorantId(), params=params) assert r.status_code == 200, r.status_code
def test_get_student_byId(): r = requests.get(a.api_link() + "student/" + a.studentId()) assert r.status_code == 200, r.status_code v = Validator(a.s_studentData()) assert v.validate(r.json()) == True, v.errors
def test_get_message_byId(): r = requests.get(a.api_link() + "message/1") assert r.status_code == 200, r.status_code
def test_get_coach_byId(): r = requests.get(a.api_link() + "coach/" + a.coachId()) assert r.status_code == 200, r.status_code v = Validator(a.s_coach()) assert v.validate(r.json()) == True, v.errors
def test_get_student(): r = requests.get(a.api_link() + "students/search") assert r.status_code == 200, r.status_code assert len(r.json()) > 1, len(r.json()) v = Validator(a.s_studentData()) assert v.validate(r.json()[0]) == True, v.errors
def test_delete_tutorant_byId(): r = requests.delete(a.api_link() + "profile/tutorant/" + a.tutorantId()) assert r.status_code == 204, r.status_code a.create_tutorant(a.tutorantId())
def test_delete_coachProfile_byId(): r = requests.delete(a.api_link() + "profile/coach/" + a.coachId()) if r.status_code is not 204: a.create_coach() assert r.status_code == 204, r.status_code a.create_coach()
import pytest import requests import os import api_info as a sup_url = a.api_link() def test_get_student(): print("test_status") r = requests.get(a.api_link() + "status") assert r.status_code == 200, r.status_code
def test_get_coachTutorant_tutorant_byId(): r = requests.get(a.api_link() + "coachTutorant/tutorant/" + a.tutorantId()) assert r.status_code == 200, r.status_code v = Validator(a.s_coachTutorant()) assert v.validate(r.json()) == True, v.errors
def test_delete_coachTutorant_coach_byId(): r = requests.delete(a.api_link() + "coachTutorant/coach/" + a.coachId()) if r.status_code is not 204: a.create_multiple_coachTutorant() assert r.status_code == 204, r.status_code a.create_multiple_coachTutorant()
def test_get_student(): print("test_status") r = requests.get(a.api_link() + "status") assert r.status_code == 200, r.status_code
def test_delete_coachTutorant_tutorant_byId(): r = requests.delete(a.api_link() + "coachTutorant/tutorant/" + a.tutorantId()) if r.status_code is not 204: a.create_coachTutorant(a.tutorantId()) assert r.status_code == 204, r.status_code a.create_coachTutorant(a.tutorantId())