Skip to content

Commit

Permalink
get_timeframe covered
Browse files Browse the repository at this point in the history
  • Loading branch information
wderocco8 committed Jul 14, 2024
1 parent 6b806d1 commit b508bf9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chalicelib/services/EventService.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_timeframe(self, timeframe_data: dict):

def get_timeframe(self, timeframe_id: str):
timeframe = self.mongo_module.get_document_by_id(
f"{self.collection_prefix}timeframe", timeframe_id
collection=f"{self.collection_prefix}timeframe", document_id=timeframe_id
)

return json.dumps(timeframe, cls=self.BSONEncoder)
Expand Down
58 changes: 56 additions & 2 deletions tests/services/test_event_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
from unittest.mock import MagicMock, patch
from chalicelib.services.EventService import EventService
import datetime
import json

with open("tests/fixtures/events/general/sample_timeframes.json") as f:
SAMPLE_TIMEFRAMES: list = json.load(f)

with open("tests/fixtures/events/general/sample_timeframe_sheets.json") as f:
SAMPLE_TIMEFRAME_SHEETS: list = json.load(f)

with open("tests/fixtures/events/general/sample_rush_events.json") as f:
SAMPLE_RUSH_EVENTS: list = json.load(f)

with open("tests/fixtures/events/general/sample_rush_event.json") as f:
SAMPLE_RUSH_EVENT = json.load(f)

@pytest.fixture
def mock_mongo_module():
Expand All @@ -14,7 +26,6 @@ def mock_mongo_module():
def event_service(mock_mongo_module):
return EventService(mock_mongo_module)


def test_insert_document(event_service, mock_mongo_module):
CREATE_TIMEFRAME = { "name": "testTimeframeName", "spreadsheetId": "testSpreadsheetId" }
dateCreated = datetime.datetime.now()
Expand All @@ -27,4 +38,47 @@ def test_insert_document(event_service, mock_mongo_module):
collection="events-timeframe", data=CREATE_TIMEFRAME
)

assert result == {"msg": True}
assert result == {"msg": True}

def test_get_timeframe(event_service, mock_mongo_module):
mock_mongo_module.get_document_by_id.return_value = SAMPLE_TIMEFRAMES[0]
timeframe_id = SAMPLE_TIMEFRAMES[0]["_id"]

result = event_service.get_timeframe(timeframe_id=timeframe_id)
mock_mongo_module.get_document_by_id.assert_called_once_with(
collection="events-timeframe", document_id=timeframe_id
)

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

# TODO:

# def get_all_timeframes(self):

# def delete_timeframe(self, timeframe_id: str):

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

# def get_event(self, event_id: str):

# def checkin(self, event_id: str, user: dict) -> dict:

# def delete(self, event_id: str):

# def get_timeframe_sheets(self, timeframe_id: str):

# def get_rush_categories_and_events(self):

# def create_rush_category(self, data: dict):

# def create_rush_event(self, data: dict):

# def modify_rush_event(self, data: dict):

# def modify_rush_settings(self, data: dict):

# def get_rush_event(self, event_id: str, hide_attendees: bool = True):

# def checkin_rush(self, event_id: str, user_data: dict):

# def delete_rush_event(self, event_id: str):

0 comments on commit b508bf9

Please sign in to comment.