def test_put_todo_valid_body(num): t_start = datetime.utcnow().timestamp() reset_system() init_existing_todos(num=num) # Given headers = {'Content-Type': 'application/json'} todo = { 'title': 'Task title 1', 'doneStatus': False, 'description': 'this is a description' } todo_id = create_todo(todo)['id'] edited_todo = { 'title': 'A different title', 'doneStatus': True, 'description': 'a different description' } t_start_call = datetime.utcnow().timestamp() # When res = requests.put(url + '/' + todo_id, headers=headers, data=json.dumps(edited_todo)) t_end_call = datetime.utcnow().timestamp() res_body = res.json() # Then print_response(res) assert res.status_code == 200 assert res_body['id'] == todo_id assert res_body['title'] == edited_todo['title'] assert res_body['doneStatus'] == str(edited_todo['doneStatus']).lower() assert res_body['description'] == edited_todo['description'] t_end = datetime.utcnow().timestamp() t1 = t_end - t_start t2 = t_end_call - t_start_call f = open("perf_logs/modify_todo_performance_test.csv", "a") f.write( str(datetime.now().isoformat()) + ',' + str(num) + ',' + str(t1) + ',' + str(t2) + '\n') f.close()
def test_modify_category(num): t_start = datetime.utcnow().timestamp() reset_system() init_existing_categories(num=num) # Given headers = {'Content-Type': 'application/json'} category = { 'title': 'Category title 1', 'description': 'this is a description' } category_id = create_category(category)['id'] edited_category = { 'title': 'A different title', 'description': 'a different description' } t_start_call = datetime.utcnow().timestamp() # When res = requests.put(url + '/' + category_id, headers=headers, data=json.dumps(edited_category)) t_end_call = datetime.utcnow().timestamp() res_body = res.json() # Then print_response(res) assert res.status_code == 200 assert res_body['id'] == category_id assert res_body['title'] == edited_category['title'] assert res_body['description'] == edited_category['description'] t_end = datetime.utcnow().timestamp() t1 = t_end - t_start t2 = t_end_call - t_start_call f = open("perf_logs/modify_category_performance_test.csv", "a") f.write( str(datetime.now().isoformat()) + ',' + str(num) + ',' + str(t1) + ',' + str(t2) + '\n') f.close()
def test_modify_project(num): t_start = datetime.utcnow().timestamp() reset_system() init_existing_projects(num=num) headers = {'Content-Type': 'application/json'} # Given project = { 'title': 'Project title 1', 'completed': False, 'active': True, 'description': 'agna aliqua. Ut enim abc' } project_change = {'title': 'Project changed title'} res_specific_project = create_project(project) specific_id = res_specific_project['id'] specific_project_id_url = url + '/' + specific_id t_start_call = datetime.utcnow().timestamp() # When res = requests.put(specific_project_id_url, headers=headers, data=json.dumps(project_change)) t_end_call = datetime.utcnow().timestamp() res_body = res.json() # Then print_response(res) assert res.status_code == 200 assert res_body['title'] == project_change['title'] t_end = datetime.utcnow().timestamp() t1 = t_end - t_start t2 = t_end_call - t_start_call f = open("perf_logs/modify_project_performance_test.csv", "a") f.write( str(datetime.now().isoformat()) + ',' + str(num) + ',' + str(t1) + ',' + str(t2) + '\n') f.close()
def test_add_todo(num): t_start = datetime.utcnow().timestamp() reset_system() init_existing_todos(num=num) headers = dict() headers = {'Content-Type': 'application/json'} # Given headers = {'Content-Type': 'application/json'} todo = { 'title': 'Task title 1', 'doneStatus': False, 'description': 'this is a description' } t_start_call = datetime.utcnow().timestamp() # When res = requests.post(url, headers=headers, data=json.dumps(todo)) t_end_call = datetime.utcnow().timestamp() res_body = res.json() # Then print_response(res) assert res.status_code == 201 assert res_body['title'] == todo['title'] assert res_body['doneStatus'] == str(todo['doneStatus']).lower() assert res_body['description'] == todo['description'] t_end = datetime.utcnow().timestamp() t1 = t_end - t_start t2 = t_end_call - t_start_call f = open("perf_logs/add_todo_performance_test.csv", "a") f.write( str(datetime.now().isoformat()) + ',' + str(num) + ',' + str(t1) + ',' + str(t2) + '\n') f.close()
def test_add_project(num): t_start = datetime.utcnow().timestamp() reset_system() init_existing_projects(num=num) headers = {'Content-Type': 'application/json'} # Given project = { 'title': 'Project title x', 'completed': False, 'active': True, 'description': 'agna aliqua. Ut enim xyz' } t_start_call = datetime.utcnow().timestamp() # When res = requests.post(url, headers=headers, data=json.dumps(project)) t_end_call = datetime.utcnow().timestamp() res_body = res.json() # Then print_response(res) assert res.status_code == 201 assert res_body['title'] == project['title'] assert res_body['description'] == project['description'] t_end = datetime.utcnow().timestamp() t1 = t_end - t_start t2 = t_end_call - t_start_call f = open("perf_logs/add_project_performance_test.csv", "a") f.write( str(datetime.now().isoformat()) + ',' + str(num) + ',' + str(t1) + ',' + str(t2) + '\n') f.close()
def test_delete_todo(num): t_start = datetime.utcnow().timestamp() reset_system() init_existing_todos(num=num) # Given headers = {'Content-Type': 'application/json'} todo = { 'title': 'Task title 1', 'doneStatus': False, 'description': 'this is a description' } todo_id = create_todo(todo)['id'] t_start_call = datetime.utcnow().timestamp() # When res = requests.delete(url + '/' + todo_id, headers=headers) t_end_call = datetime.utcnow().timestamp() # Then print_response(res) assert res.status_code == 200 t_end = datetime.utcnow().timestamp() t1 = t_end - t_start t2 = t_end_call - t_start_call f = open("perf_logs/delete_todo_performance_test.csv", "a") f.write( str(datetime.now().isoformat()) + ',' + str(num) + ',' + str(t1) + ',' + str(t2) + '\n') f.close()
def setup_function(function): reset_system() headers = dict() headers = {'Content-Type': 'application/json'}
def setup_function(function): reset_system()
def before_scenario(context, scenario): reset_system()