Additional tests
This commit is contained in:
		
							parent
							
								
									1f9ccca9bf
								
							
						
					
					
						commit
						9cca8edd9d
					
				
					 1 changed files with 55 additions and 6 deletions
				
			
		
							
								
								
									
										61
									
								
								testing.py
									
										
									
									
									
								
							
							
						
						
									
										61
									
								
								testing.py
									
										
									
									
									
								
							|  | @ -257,13 +257,9 @@ def test_sign_report(): | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     response = requests.put( |     response = requests.put( | ||||||
|         addUserToProjectPath, |         addUserToProjectPath + "/" + projectName, | ||||||
|         json={ |  | ||||||
|             "projectName": projectName, |  | ||||||
|             "username": project_manager, |  | ||||||
|             "role": "project_manager", |  | ||||||
|         }, |  | ||||||
|         headers={"Authorization": "Bearer " + admin_token}, |         headers={"Authorization": "Bearer " + admin_token}, | ||||||
|  |         params={"userName": project_manager} | ||||||
|     ) |     ) | ||||||
|     assert response.status_code == 200, "Add project manager to project failed" |     assert response.status_code == 200, "Add project manager to project failed" | ||||||
|     dprint("Project manager added to project successfully") |     dprint("Project manager added to project successfully") | ||||||
|  | @ -515,6 +511,58 @@ def test_get_unsigned_reports(): | ||||||
|         assert response.status_code == 200, "Get unsigned reports failed" |         assert response.status_code == 200, "Get unsigned reports failed" | ||||||
|         gprint("test_get_unsigned_reports successful") |         gprint("test_get_unsigned_reports successful") | ||||||
| 
 | 
 | ||||||
|  | def test_get_other_users_report_as_pm(): | ||||||
|  |     # Create user | ||||||
|  |     user = randomString() | ||||||
|  |     register(user, "password") | ||||||
|  | 
 | ||||||
|  |     # Create project | ||||||
|  |     project = randomString() | ||||||
|  |     pm_token = login(user, "password").json()["token"] | ||||||
|  |     response = requests.post( | ||||||
|  |         addProjectPath, | ||||||
|  |         json={"name": project, "description": "This is a project"}, | ||||||
|  |         headers={"Authorization": "Bearer " + pm_token}, | ||||||
|  |     ) | ||||||
|  |     assert response.status_code == 200, "Add project failed" | ||||||
|  | 
 | ||||||
|  |     # Create other user | ||||||
|  |     other_user = randomString() | ||||||
|  |     register(other_user, "password") | ||||||
|  |     user_token = login(other_user, "password").json()["token"] | ||||||
|  | 
 | ||||||
|  |     # Add other user to project | ||||||
|  |     response = requests.put( | ||||||
|  |         addUserToProjectPath + "/" + project, | ||||||
|  |         headers={"Authorization": "Bearer " + pm_token}, # note pm_token | ||||||
|  |         params={"userName": other_user}, | ||||||
|  |     ) | ||||||
|  |     assert response.status_code == 200, "Add user to project failed" | ||||||
|  | 
 | ||||||
|  |     # Submit report as other user | ||||||
|  |     response = requests.post( | ||||||
|  |         submitReportPath, | ||||||
|  |         json={ | ||||||
|  |             "projectName": project, | ||||||
|  |             "week": 1, | ||||||
|  |             "developmentTime": 10, | ||||||
|  |             "meetingTime": 5, | ||||||
|  |             "adminTime": 5, | ||||||
|  |             "ownWorkTime": 10, | ||||||
|  |             "studyTime": 10, | ||||||
|  |             "testingTime": 10, | ||||||
|  |         }, | ||||||
|  |         headers={"Authorization": "Bearer " + user_token}, | ||||||
|  |     ) | ||||||
|  |     assert response.status_code == 200, "Submit report failed" | ||||||
|  | 
 | ||||||
|  |     # Get report as project manager | ||||||
|  |     response = requests.get( | ||||||
|  |         getWeeklyReportPath, | ||||||
|  |         headers={"Authorization": "Bearer " + pm_token}, | ||||||
|  |         params={"targetUser": other_user, "projectName": project, "week": 1}, | ||||||
|  |     ) | ||||||
|  |     assert response.status_code == 200, "Get weekly report failed" | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     test_remove_project() |     test_remove_project() | ||||||
|  | @ -535,4 +583,5 @@ if __name__ == "__main__": | ||||||
|     test_list_all_users_project() |     test_list_all_users_project() | ||||||
|     test_change_user_name() |     test_change_user_name() | ||||||
|     test_update_weekly_report() |     test_update_weekly_report() | ||||||
|  |     test_get_other_users_report_as_pm() | ||||||
|      |      | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus