Skip to content

Commit

Permalink
#503 unittests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
danmash committed Nov 22, 2023
1 parent 3403dd7 commit 588bd4c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 1 addition & 4 deletions app/analytics/analytics_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ def log_user_a_event(
event_to_add.action = action
event_to_add.label = label
event_to_add.value = event_value
event_to_add.event_timestamp = datetime.strptime(
str(event_timestamp), "%Y-%m-%d %H:%M:%S"
)
event_to_add.event_timestamp = event_timestamp
event_to_add.page_url = page_url
# event_to_add.event_timestamp = datetime.now(timezone.utc)
db.session.add(event_to_add)
db.session.commit()
except:
Expand Down
4 changes: 3 additions & 1 deletion app/session/tests/test_session_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def test_store_session_creation(
assert Sessions.query.count() == 1, "Single session should be created"
created_session = Sessions.query.first()
assert created_session.session_uuid == session_uuid
assert created_session.session_created_timestamp == session_created_timestamp
db_time = created_session.session_created_timestamp.isoformat(" ", "seconds")
expected_time = session_created_timestamp.isoformat(" ", "seconds")
assert db_time == expected_time
assert created_session.user_uuid == user_uuid
assert created_session.ip_address == ip_address

Expand Down
6 changes: 3 additions & 3 deletions app/session/tests/test_session_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_post_session_creates_unique_uuids(client):
assert (
session.session_uuid == response_uuid
), "The endpoint should return same UUID as stored in DB"
assert (
session.session_created_timestamp == faked_now
), "The session object has been created now"
db_time = session.session_created_timestamp.isoformat(" ", "seconds")
expected_time = faked_now.isoformat(" ", "seconds")
assert db_time == expected_time, "The session object has been created now"
assert session.user_uuid == user.user_uuid, "Mocked user linked"

0 comments on commit 588bd4c

Please sign in to comment.