Skip to content

Commit

Permalink
bugfix: fixed waitlist test
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSoft007 committed Aug 23, 2024
1 parent 24c7acd commit 853b3ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 62 deletions.
59 changes: 0 additions & 59 deletions api/v1/routes/waitlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,65 +71,6 @@ async def waitlist_signup(
)
return success_response(message="You are all signed up!", status_code=201)

# @waitlist.post("/", response_model=success_response, status_code=201)
# async def waitlist_signup(
# background_tasks: BackgroundTasks, request: Request, user: WaitlistAddUserSchema, db: Session = Depends(get_db)
# ):
# if not user.full_name:
# logger.error("Full name is required")
# raise HTTPException(
# status_code=422,
# detail={
# "message": "Full name is required",
# "success": False,
# "status_code": 422,
# },
# )

# existing_user = find_existing_user(db, user.email)
# if existing_user:
# logger.error(f"Email already registered: {user.email}")
# raise HTTPException(
# status_code=400,
# detail={
# "message": "Email already registered",
# "success": False,
# "status_code": 400,
# },
# )

# db_user = add_user_to_waitlist(db, user.email, user.full_name)

# try:
# if db_user:
# cta_link = 'https://anchor-python.teams.hng.tech/about-us'
# # Send email in the background
# background_tasks.add_task(
# send_email,
# recipient=user.email,
# template_name='waitlist.html',
# subject='Welcome to HNG Waitlist',
# context={
# 'name': user.full_name,
# 'cta_link': cta_link
# }
# )
# # await send_confirmation_email(user.email, user.full_name)
# logger.info(f"Confirmation email sent successfully to {user.email}")
# except HTTPException as e:
# logger.error(f"Failed to send confirmation email: {e.detail}")
# raise HTTPException(
# status_code=500,
# detail={
# "message": "Failed to send confirmation email",
# "success": False,
# "status_code": 500,
# },
# )

# logger.info(f"User signed up successfully: {user.email}")
# return success_response(message="You are all signed up!", status_code=201)


@waitlist.post(
"/admin",
Expand Down
6 changes: 3 additions & 3 deletions tests/v1/waitlist/waitlist_email_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_waitlist_signup(mock_send_email, client_with_mocks):
assert response.status_code == 201


def test_duplicate_email(client_with_mocks):
def test_duplicate_email(mock_send_email, client_with_mocks):
client, mock_db = client_with_mocks
# Simulate an existing user in the database
mock_db.query.return_value.filter.return_value.first.return_value = MagicMock()
Expand All @@ -53,14 +53,14 @@ def test_duplicate_email(client_with_mocks):
)
assert response.status_code == 400

def test_invalid_email(client_with_mocks):
def test_invalid_email(mock_send_email, client_with_mocks):
client, _ = client_with_mocks
response = client.post(
"/api/v1/waitlist/", json={"email": "invalid_email", "full_name": "Test User"}
)
assert response.status_code == 422

def test_signup_with_empty_name(client_with_mocks):
def test_signup_with_empty_name(mock_send_email, client_with_mocks):
client, _ = client_with_mocks
response = client.post(
"/api/v1/waitlist/", json={"email": "[email protected]", "full_name": ""}
Expand Down

0 comments on commit 853b3ee

Please sign in to comment.