Skip to content

Commit

Permalink
updated variable namings
Browse files Browse the repository at this point in the history
  • Loading branch information
wderocco8 committed Jul 14, 2024
1 parent b508bf9 commit 72372a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions chalicelib/services/EventService.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def delete_timeframe(self, timeframe_id: str):
self.mongo_module.delete_document_by_id(
f"{self.collection_prefix}timeframe", timeframe_id
)

return {"statusCode": 200}

def create_event(self, timeframe_id: str, event_data: dict):
event_data["dateCreated"] = datetime.datetime.now()
Expand Down
29 changes: 22 additions & 7 deletions tests/services/test_event_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def event_service(mock_mongo_module):

def test_insert_document(event_service, mock_mongo_module):
CREATE_TIMEFRAME = { "name": "testTimeframeName", "spreadsheetId": "testSpreadsheetId" }
dateCreated = datetime.datetime.now()
date_created = datetime.datetime.now()

with patch("chalicelib.services.EventService.datetime") as mock_datetime:
mock_datetime.datetime.now.return_value = dateCreated
mock_datetime.datetime.now.return_value = date_created
result = event_service.create_timeframe(CREATE_TIMEFRAME)
CREATE_TIMEFRAME["dateCreated"] = dateCreated
CREATE_TIMEFRAME["date_created"] = date_created
mock_mongo_module.insert_document.assert_called_once_with(
collection="events-timeframe", data=CREATE_TIMEFRAME
)
Expand All @@ -51,13 +51,28 @@ def test_get_timeframe(event_service, mock_mongo_module):

assert result == json.dumps(SAMPLE_TIMEFRAMES[0])

# TODO:
def test_get_all_timeframe(event_service, mock_mongo_module):
mock_mongo_module.get_all_data_from_collection.return_value = SAMPLE_TIMEFRAMES

result = event_service.get_all_timeframes()
mock_mongo_module.get_all_data_from_collection.assert_called_once_with(
collection="events-timeframe"
)

# def get_all_timeframes(self):
assert result == json.dumps(SAMPLE_TIMEFRAMES)

# def delete_timeframe(self, timeframe_id: str):
def test_delete_timeframe(event_service, mock_mongo_module):
result = event_service.delete_timeframe(timeframe_id=SAMPLE_TIMEFRAMES[0]["_id"])
assert result["statusCode"] == 200

# def create_event(self, timeframe_id: str, event_data: dict):

# TODO: potentially add mocking for GoogleSheetsModule (otherwise test is not isolated)
# def test_create_event(event_service, mock_mongo_module):
# CREATE_TIMEFRAME = { "name": "eventName", "tags": "tags", "sheetTab": "selectedSheetTab" }
# date_created = datetime.datetime.now()
# timeframe_id = "timeframeId"

# TODO:

# def get_event(self, event_id: str):

Expand Down

0 comments on commit 72372a0

Please sign in to comment.