backend/feature/supabase #60
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -270,8 +270,8 @@ def get_toilets(location: tuple[float, float] = Query(...), radius: int = 500) - | ||||
|         raise HTTPException(status_code=404, detail="No toilets found") from exc | ||||
|  | ||||
|  | ||||
| @app.post("/user/create") | ||||
| def register_user(email: str = Body(...), password: str = Body(...)) -> str: | ||||
| @app.post("/user/create/{email}/{password}") | ||||
| def register_user(email: str, password: str) -> str: | ||||
|     try: | ||||
|         response = supabase.supabase.auth.admin.create_user({ | ||||
|             "email": email, | ||||
| @@ -293,11 +293,11 @@ def register_user(email: str = Body(...), password: str = Body(...)) -> str: | ||||
|  | ||||
|  | ||||
|  | ||||
| @app.post("/user/delete") | ||||
| def delete_user(request: UserDeleteRequest): | ||||
| @app.post("/user/delete/{user_id}") | ||||
| def delete_user(user_id: str): | ||||
|  | ||||
|     try: | ||||
|         response = supabase.supabase.auth.admin.delete_user(request.user_id) | ||||
|         response = supabase.supabase.auth.admin.delete_user(user_id) | ||||
|         logger.debug(response) | ||||
|     except Exception as e: | ||||
|         if e.code == 'user_not_found' : | ||||
| @@ -306,6 +306,6 @@ def delete_user(request: UserDeleteRequest): | ||||
|         logger.error(f"Failed to create user : {str(e.code)}") | ||||
|         raise HTTPException(status_code=500, detail=str(e)) from e | ||||
|      | ||||
|     logger.info(f"User with ID {request.user_id} deleted successfully") | ||||
|     logger.info(f"User with ID {user_id} deleted successfully") | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -19,50 +19,30 @@ def test_user_handling(client) : | ||||
|     Test the creation of a new user. | ||||
|     """ | ||||
|     # Create a new user | ||||
|     response = client.post( | ||||
|         "/user/create",  | ||||
|         json={ | ||||
|             "email": TEST_EMAIL, | ||||
|             "password": TEST_PW | ||||
|             } | ||||
|         ) | ||||
|     response = client.post(f"/user/create/{TEST_EMAIL}/{TEST_PW}") | ||||
|  | ||||
|     # Verify user has been created | ||||
|     assert response.status_code == 200 | ||||
|     assert response.status_code == 200, "Failed to create dummy user" | ||||
|     user_id = response.json() | ||||
|  | ||||
|     # # Create same user again to raise an error | ||||
|     response = client.post( | ||||
|         "/user/create",  | ||||
|         json={ | ||||
|             "email": TEST_EMAIL, | ||||
|             "password": TEST_PW | ||||
|             } | ||||
|         ) | ||||
|  | ||||
|     # Create same user again to raise an error | ||||
|     response = client.post(f"/user/create/{TEST_EMAIL}/{TEST_PW}") | ||||
|     # Verify user already exists | ||||
|     assert response.status_code == 422 | ||||
|     assert response.status_code == 422, "Failed to simulate dummy user already created." | ||||
|  | ||||
|  | ||||
|     # Delete the user. | ||||
|     response = client.post( | ||||
|         "/user/delete",  | ||||
|         json={ | ||||
|             "user_id": user_id | ||||
|             } | ||||
|         ) | ||||
|     print(response) | ||||
|     response = client.post(f"/user/delete/{user_id}") | ||||
|  | ||||
|     # Verify user has been deleted | ||||
|     assert response.status_code == 200, "Failed to delete dummy user." | ||||
|  | ||||
|  | ||||
|     # Delete the user again to raise an error | ||||
|     response = client.post( | ||||
|         "/user/delete",  | ||||
|         json={ | ||||
|             "user_id": user_id | ||||
|             } | ||||
|         ) | ||||
|     print(response) | ||||
|     response = client.post(f"/user/delete/{user_id}") | ||||
|     # Verify user has been deleted | ||||
|     assert response.status_code == 404, "Failed to delete dummy user." | ||||
|     assert response.status_code == 404, "Failed to simulate dummy user already deleted." | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -134,7 +134,7 @@ class ClusterManager: | ||||
|  | ||||
|                 # Check that there are is least 1 cluster | ||||
|                 if len(set(labels)) > 1 : | ||||
|                     self.logger.info(f"Found {len(set(labels))} different {cluster_type} clusters.") | ||||
|                     self.logger.info(f"Found {len(set(labels))} {cluster_type} clusters.") | ||||
|                     # Separate clustered points and noise points | ||||
|                     self.cluster_points = self.all_points[labels != -1] | ||||
|                     self.cluster_labels = labels[labels != -1] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user