better endpoints
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m15s
Run linting on the backend code / Build (pull_request) Successful in 27s
Run testing on the backend code / Build (pull_request) Failing after 48s
Build and release debug APK / Build APK (pull_request) Failing after 4m38s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 25s
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m15s
Run linting on the backend code / Build (pull_request) Successful in 27s
Run testing on the backend code / Build (pull_request) Failing after 48s
Build and release debug APK / Build APK (pull_request) Failing after 4m38s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 25s
This commit is contained in:
parent
fd091a9ccc
commit
f258df8e72
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
|
raise HTTPException(status_code=404, detail="No toilets found") from exc
|
||||||
|
|
||||||
|
|
||||||
@app.post("/user/create")
|
@app.post("/user/create/{email}/{password}")
|
||||||
def register_user(email: str = Body(...), password: str = Body(...)) -> str:
|
def register_user(email: str, password: str) -> str:
|
||||||
try:
|
try:
|
||||||
response = supabase.supabase.auth.admin.create_user({
|
response = supabase.supabase.auth.admin.create_user({
|
||||||
"email": email,
|
"email": email,
|
||||||
@ -293,11 +293,11 @@ def register_user(email: str = Body(...), password: str = Body(...)) -> str:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/user/delete")
|
@app.post("/user/delete/{user_id}")
|
||||||
def delete_user(request: UserDeleteRequest):
|
def delete_user(user_id: str):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = supabase.supabase.auth.admin.delete_user(request.user_id)
|
response = supabase.supabase.auth.admin.delete_user(user_id)
|
||||||
logger.debug(response)
|
logger.debug(response)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if e.code == 'user_not_found' :
|
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)}")
|
logger.error(f"Failed to create user : {str(e.code)}")
|
||||||
raise HTTPException(status_code=500, detail=str(e)) from e
|
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.
|
Test the creation of a new user.
|
||||||
"""
|
"""
|
||||||
# Create a new user
|
# Create a new user
|
||||||
response = client.post(
|
response = client.post(f"/user/create/{TEST_EMAIL}/{TEST_PW}")
|
||||||
"/user/create",
|
|
||||||
json={
|
|
||||||
"email": TEST_EMAIL,
|
|
||||||
"password": TEST_PW
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# Verify user has been created
|
# Verify user has been created
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200, "Failed to create dummy user"
|
||||||
user_id = response.json()
|
user_id = response.json()
|
||||||
|
|
||||||
# # Create same user again to raise an error
|
|
||||||
response = client.post(
|
# Create same user again to raise an error
|
||||||
"/user/create",
|
response = client.post(f"/user/create/{TEST_EMAIL}/{TEST_PW}")
|
||||||
json={
|
|
||||||
"email": TEST_EMAIL,
|
|
||||||
"password": TEST_PW
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# Verify user already exists
|
# Verify user already exists
|
||||||
assert response.status_code == 422
|
assert response.status_code == 422, "Failed to simulate dummy user already created."
|
||||||
|
|
||||||
|
|
||||||
# Delete the user.
|
# Delete the user.
|
||||||
response = client.post(
|
response = client.post(f"/user/delete/{user_id}")
|
||||||
"/user/delete",
|
|
||||||
json={
|
|
||||||
"user_id": user_id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
print(response)
|
|
||||||
# Verify user has been deleted
|
# Verify user has been deleted
|
||||||
assert response.status_code == 200, "Failed to delete dummy user."
|
assert response.status_code == 200, "Failed to delete dummy user."
|
||||||
|
|
||||||
|
|
||||||
# Delete the user again to raise an error
|
# Delete the user again to raise an error
|
||||||
response = client.post(
|
response = client.post(f"/user/delete/{user_id}")
|
||||||
"/user/delete",
|
|
||||||
json={
|
|
||||||
"user_id": user_id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
print(response)
|
|
||||||
# Verify user has been deleted
|
# 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
|
# Check that there are is least 1 cluster
|
||||||
if len(set(labels)) > 1 :
|
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
|
# Separate clustered points and noise points
|
||||||
self.cluster_points = self.all_points[labels != -1]
|
self.cluster_points = self.all_points[labels != -1]
|
||||||
self.cluster_labels = labels[labels != -1]
|
self.cluster_labels = labels[labels != -1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user