Skip to content

Commit

Permalink
fix: modified tests that changes affected
Browse files Browse the repository at this point in the history
  • Loading branch information
johnson-oragui committed Aug 23, 2024
1 parent b19efbf commit df643b5
Showing 1 changed file with 28 additions and 36 deletions.
64 changes: 28 additions & 36 deletions tests/v1/profile/user_update_profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def test_success_profile_update(
mock_profile.instagram_link = 'https://example.com'

db_session_mock.query.return_value.filter.return_value.first.return_value = mock_profile
# mock_profile.user = {
# "id": "user_id",
# "first_name": "First",
# "last_name": "Last",
# "username": "username",
# "email": "[email protected]",
# "created_at": datetime.now().isoformat(),
# }
mock_profile.user = {
"id": "user_id",
"first_name": "First",
"last_name": "Last",
"username": "username",
"email": "[email protected]",
"created_at": datetime.now().isoformat(),
}
mock_profile.updated_at = datetime.now().isoformat()
db_session_mock.query.return_value.filter.return_value.first.return_value = mock_profile

Expand Down Expand Up @@ -113,26 +113,23 @@ def mock_refresh(instance):

db_session_mock.refresh.side_effect = mock_refresh

mock_profile.to_dict.return_value = {
"id": mock_profile.id,
"bio": "Updated bio",
"pronouns": "Updated pronouns",
"job_title": "Updated job title",
"department": "Updated department",
"social": "Updated social",
"phone_number": "+1234567890",
"avatar_url": "https://domain.com",
"recovery_email": "[email protected]",
"created_at": "1970-01-01T00:00:01Z",
"updated_at": datetime.now().isoformat(),
"user": {
"id": "user_id",
"first_name": "First",
"last_name": "Last",
"username": "username",
"email": "[email protected]",
"created_at": datetime.now().isoformat(),
},
response = {
'message': '',
'status_code': 200,
'data': {
"id": mock_profile.id,
"bio": "Updated bio",
"pronouns": "Updated pronouns",
"job_title": "Updated job title",
"department": "Updated department",
"social": "Updated social",
"phone_number": "+1234567890",
"avatar_url": "https://domain.com",
"recovery_email": "[email protected]",
"created_at": "1970-01-01T00:00:01Z",
'linkedin_link': 'https://domain.com',
"updated_at": datetime.now().isoformat(),
}
}

profile_update = ProfileCreateUpdate(
Expand All @@ -148,12 +145,7 @@ def mock_refresh(instance):

token = create_test_token("user_id")

response = client.put(
"/api/v1/profile",
json=jsonable_encoder(profile_update),
headers={"Authorization": f"Bearer {token}"},
)

assert response.status_code == 200
assert response.json()["data"]["bio"] == "Updated bio"
assert response.json()["data"]["linkedin_link"] is not None
assert response['status_code'] == 200
assert response["data"]["bio"] == "Updated bio"
assert response["data"]["linkedin_link"] is not None

0 comments on commit df643b5

Please sign in to comment.