def test_event_application_creation(self): body = { "record_number": "1", "client_name": "elina", "event_type": "party", "description": "none", "from_date": "2020/10/23", "to_date": "2020/10/30", "expected_number_attendees": "20", "planned_budget": "2000", "decorations": "balloon", "food_drinks": "BBQ, dessert and cider", "filming_photos": "yes", "music": "pop music", "posters_art_work": "none", "computer_related_issues": "none", "other_needs": "none" } username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} http_request.request("POST", "/event_application_creation", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200) global application_id_tested application_id_tested = json.loads( response.read().decode())["project_reference"]
def test_client_exists(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) self.assertEqual(response["username"], username) self.assertIsNot(response["token"], str()) global token token = response["token"] return token
def test_authorize_fm(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} http_request.request("GET", "/authorized_FM/", headers=header) response = http_request.getresponse() decoded_response = json.loads(response.read().decode()) print(decoded_response) print(token) self.assertEqual(response.status, 200)
def test_update_staff_request(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} body = {"staff_request_id": staff_request_id, "status": "done"} http_request.request('PUT', "/review_staff_request/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200)
def test_event_application_retrieve(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} body = {"application_id": application_id_tested} http_request.request("GET", "/event_application_retrieve/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200)
def test_update_financial_request(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} body = {"financial_request_id": financial_request_id, "status": "done"} http_request.request("PUT", "/review_financial_request/", headers=header, body=json.dumps(body)) response = http_request.getresponse() print(response.read().decode()) self.assertEqual(response.status, 200)
def test_task_vdelete(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = { 'Authorization': 'Bearer {}'.format(response.get("token")) } body = { "task_id": tasks[0], } http_request.request("DELETE", "/retrieve_task/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200)
def test_task_retrieve(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = { 'Authorization': 'Bearer {}'.format(response.get("token")) } http_request.request("GET", "/retrieve_task/", headers=header, body=json.dumps(dict())) response = http_request.getresponse() decoded_response = json.loads(response.read().decode()) for task in decoded_response["tasks"]: global tasks tasks.append(task["task_id"]) self.assertGreaterEqual(len(tasks), 1) self.assertEqual(response.status, 200)
def test_review_feedback(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response["token"])} body = { "record_number": "{}".format(event_id_tested), "feedback": financial_manager_feedback } http_request.request("PUT", "/review_event_creation/", headers=header, body=json.dumps(body)) response = http_request.getresponse() print(response.read().decode()) self.assertEqual(response.status, 200)
def test_review(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response["token"])} body = { "record_number": "{}".format(event_id_tested), "status": "accepted" } http_request.request("PUT", "/review_event_creation/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200)
def test_retrieve(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} http_request.request("GET", "/review_event_creation/", headers=header) response = http_request.getresponse() decoded_response = json.loads(response.read().decode()) print(decoded_response) event_ids = list() for event in decoded_response.values(): event_ids = [e["event_request_id"] for e in event] global event_id_tested event_id_tested = event_ids[0] self.assertEqual(response.status, 200)
def test_retrieve_staff_request(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} http_request.request('GET', "/review_staff_request/", headers=header, body=json.dumps(dict())) response = http_request.getresponse() self.assertEqual(response.status, 200) decoded_response = json.loads(response.read().decode()).values() staff_requests = list() for staff in decoded_response: staff_requests = [s["staff_request_id"] for s in staff] global staff_request_id staff_request_id = staff_requests[0]
def test_create_staff_request(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} body = { "is_full_time": "true", "request_department": "production", "year_experience_min": 5, "job_title": "Photographer", "job_description": "Take photos at a party wedding" } http_request.request("POST", "/create_staff_request/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200)
def test_retrieve_financial_request(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} http_request.request("GET", "/review_financial_request/", headers=header, body=json.dumps(dict())) response = http_request.getresponse() self.assertEqual(response.status, 200) financial_ids = list() financial_requests = json.loads(response.read().decode()) for financial_request in financial_requests["financial_requests"]: financial_ids.append( financial_request.get("financial_request_id", str())) if financial_request_id != str(): self.assertIn(financial_request_id, financial_ids) else: self.assertGreaterEqual(len(financial_ids), 0)
def test_task_creation(self): """ Expecting project_reference, username the one assigned, priority and description :return: """ username, password = "******", "password" response = authenticate_client(username, password, http_request) header = { 'Authorization': 'Bearer {}'.format(response.get("token")) } body = { "project_reference": project_reference, "user_assigned": "chris", "description": "Create schedule for next meeting", "priority": "high" } http_request.request("POST", "/create_task/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200)
def test_event_creation(self): body = { "client_name": "elina", "event_type": "party", "from_date": "2020/10/23", "to_date": "2020/10/30", "expected_number_attendees": "20", "preferences": "parties" } username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} http_request.request("POST", "/event_creation/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200)
def test_create_financial_request(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} body = { "request_department": "production", "project_reference": project_reference, "required_amount": 5000, "reason": "Need more resources" } http_request.request("POST", "/create_financial_request/", headers=header, body=json.dumps(body)) response = http_request.getresponse() self.assertEqual(response.status, 200) global financial_request_id financial_request_id = json.loads( response.read().decode())["financial_request_id"] self.assertIsNot(financial_request_id, str())
def test_application_retrieve(self): # 695e5341-793b-4f3e-aee6-d44fa254d9c8 username, password = "******", "password" response = authenticate_client(username, password, http_request) header = { 'Authorization': 'Bearer {}'.format(response.get("token")) } body = {} http_request.request("GET", "/event_application_retrieve/", headers=header, body=json.dumps(body)) response = http_request.getresponse() decoded_response = json.loads(response.read().decode()) if not decoded_response["applications"]: raise AssertionError( "No application exists, we can't launch financial request creation, further tests will fail") projects_references = list() for each_application in json.loads(response.read().decode()).values(): projects_references = [e["project_reference"] for e in each_application] global project_reference project_reference = projects_references[0] self.assertEqual(response.status, 200)
def test_application_retrieve(self): username, password = "******", "password" response = authenticate_client(username, password, http_request) header = {'Authorization': 'Bearer {}'.format(response.get("token"))} http_request.request("GET", "/event_application_retrieve/", headers=header, body=json.dumps({})) response = http_request.getresponse() self.assertEqual(response.status, 200) decoded_response = json.loads(response.read().decode()) applications_references = list() if not decoded_response["applications"]: raise AssertionError( "No application exists, we can't launch financial request creation, further tests will fail" ) for each_application in decoded_response["applications"]: applications_references.append( each_application["project_reference"]) global project_reference project_reference = applications_references[0]