def test_get_reads_expected_file(self, mock_open): store = FileEventCursorStore(PROFILE_NAME) store.get(CURSOR_NAME) user_path = path.join(path.expanduser("~"), ".code42cli") expected_path = path.join(user_path, FILE_EVENT_CHECKPOINT_FOLDER_NAME, PROFILE_NAME, CURSOR_NAME) mock_open.assert_called_once_with(expected_path)
def test_get_reads_expected_file(self, mock_open): store = FileEventCursorStore(PROFILE_NAME) store.get(CURSOR_NAME) user_path = path.join(path.expanduser("~"), ".code42cli") expected_path = path.join( user_path, "file_event_checkpoints", PROFILE_NAME, CURSOR_NAME ) mock_open.assert_called_once_with(expected_path)
def test_get_when_profile_does_not_exist_returns_none(self, mocker): store = FileEventCursorStore(PROFILE_NAME) checkpoint = store.get(CURSOR_NAME) mock_open = mocker.patch(f"{_NAMESPACE}.open") mock_open.side_effect = FileNotFoundError assert checkpoint is None
def test_get_returns_expected_timestamp(self, mock_open): store = FileEventCursorStore(PROFILE_NAME) checkpoint = store.get(CURSOR_NAME) assert checkpoint == 123456789