コード例 #1
0
ファイル: tests.py プロジェクト: jjst/RSVPBot
    def test_add_to_gcal_with_complete_event_works(self, mock):
        rsvp_bot_event = {
            u'name': 'Testing',
            u'description': 'A very fun party',
            u'date': '2100-02-25',
            u'time': u'10:30',
            u'duration': 1800,
            u'place': 'Hopper!',
            u'calendar_event': None,
            u'yes': [],
            u'no': [],
            u'maybe': [],
            u'limit': None,
        }

        calendar_events.add_rsvpbot_event_to_gcal(rsvp_bot_event, 'test/test')

        event_dict = {
            'start': {
                'timeZone': 'America/New_York',
                'dateTime': '2100-02-25T10:30:00'},
            'end': {
                'timeZone': 'America/New_York',
                'dateTime': '2100-02-25T11:00:00'},
            'location': 'Hopper!',
            'summary': 'Testing',
            'description': 'A very fun party\r\rFor more information or to RSVP, see https://zulip.com#narrow/stream/test/topic/test',
            'attendees': [],
        }

        mock.assert_called_once_with(
            event_dict,
            calendar_events.GOOGLE_CALENDAR_ID,
        )
コード例 #2
0
ファイル: tests.py プロジェクト: Katee/RSVPBot
    def test_add_to_gcal_with_complete_event_works(self, mock):
        rsvp_bot_event = {
            u'name': 'Testing',
            u'description': 'A very fun party',
            u'date': '2100-02-25',
            u'time': u'10:30',
            u'duration': 1800,
            u'place': 'Hopper!',
            u'calendar_event': None,
            u'yes': [],
            u'no': [],
            u'maybe': [],
            u'limit': None,
        }

        calendar_events.add_rsvpbot_event_to_gcal(rsvp_bot_event, 'test/test')

        event_dict = {
            'start': {
                'timeZone': 'America/New_York',
                'dateTime': '2100-02-25T10:30:00'},
            'end': {
                'timeZone': 'America/New_York',
                'dateTime': '2100-02-25T11:00:00'},
            'location': 'Hopper!',
            'summary': 'Testing',
            'description': 'A very fun party\r\rFor more information or to RSVP, see https://recurse.zulipchat.com#narrow/stream/test/topic/test',
            'attendees': [],
        }

        mock.assert_called_once_with(
            event_dict,
            calendar_events.GOOGLE_CALENDAR_ID,
        )
コード例 #3
0
ファイル: tests.py プロジェクト: jjst/RSVPBot
    def test_add_to_gcal_with_missing_duration_throws_exception(self):
        rsvp_bot_event = {
            u'name': 'Testing',
            u'description': 'A very fun party',
            u'date': '2100-02-25',
            u'time': u'10:30',
            u'duration': None,
            u'place': 'Hopper!',
            u'calendar_event': None,
            u'yes': [],
            u'no': [],
            u'maybe': [],
            u'limit': None,
        }

        with self.assertRaises(calendar_events.DurationNotSuppliedError):
            calendar_events.add_rsvpbot_event_to_gcal(rsvp_bot_event, 'test/test')
コード例 #4
0
ファイル: tests.py プロジェクト: Katee/RSVPBot
    def test_add_to_gcal_with_missing_duration_throws_exception(self):
        rsvp_bot_event = {
            u'name': 'Testing',
            u'description': 'A very fun party',
            u'date': '2100-02-25',
            u'time': u'10:30',
            u'duration': None,
            u'place': 'Hopper!',
            u'calendar_event': None,
            u'yes': [],
            u'no': [],
            u'maybe': [],
            u'limit': None,
        }

        with self.assertRaises(calendar_events.DurationNotSuppliedError):
            calendar_events.add_rsvpbot_event_to_gcal(rsvp_bot_event, 'test/test')
コード例 #5
0
ファイル: tests.py プロジェクト: jjst/RSVPBot
    def test_add_to_calendar_with_slash_in_topic_works(self, mock):
        rsvp_bot_event = {
            u'name': 'Testing',
            u'description': 'A very fun party',
            u'date': '2100-02-25',
            u'time': u'10:30',
            u'duration': 1800,
            u'place': 'Hopper!',
            u'calendar_event': None,
            u'yes': [],
            u'no': [],
            u'maybe': [],
            u'limit': None,
        }

        calendar_events.add_rsvpbot_event_to_gcal(
            rsvp_bot_event,
            '455 Broadway/Practical web app security 6/22')

        event_dict = {
            'start': {
                'timeZone': 'America/New_York',
                'dateTime': '2100-02-25T10:30:00'},
            'end': {
                'timeZone': 'America/New_York',
                'dateTime': '2100-02-25T11:00:00'},
            'location': 'Hopper!',
            'summary': 'Testing',
            'description': 'A very fun party\r\rFor more information or to RSVP, see https://zulip.com#narrow/stream/455.20Broadway/topic/Practical.20web.20app.20security.206.2F22',
            'attendees': [],
        }

        mock.assert_called_once_with(
            event_dict,
            calendar_events.GOOGLE_CALENDAR_ID,
        )
コード例 #6
0
ファイル: rsvp_commands.py プロジェクト: munyari/RSVPBot
  def run(self, events, *args, **kwargs):
    event = kwargs.pop('event')
    event_id = kwargs.pop('event_id')

    try:
      cal_event = calendar_events.add_rsvpbot_event_to_gcal(event, event_id)
    except calendar_events.KeyfilePathNotSpecifiedError:
      body = strings.ERROR_CALENDAR_ENVS_NOT_SET
    except calendar_events.DateAndTimeNotSuppliedError:
      body = strings.ERROR_DATE_AND_TIME_NOT_SET
    except calendar_events.DurationNotSuppliedError:
      body = strings.ERROR_DURATION_NOT_SET
    else:
      event['calendar_event'] = {}
      event['calendar_event']['id'] = cal_event.get('id')
      event['calendar_event']['html_link'] = cal_event.get('htmlLink')
      body = strings.MSG_ADDED_TO_CALENDAR.format(
          calendar_name=cal_event.get('calendar_name'),
          url=cal_event.get('htmlLink'))

    return RSVPCommandResponse(events, RSVPMessage('stream', body))
コード例 #7
0
ファイル: rsvp_commands.py プロジェクト: anniecherk/RSVPBot
  def run(self, events, *args, **kwargs):
    event = kwargs.pop('event')
    event_id = kwargs.pop('event_id')

    try:
      cal_event = calendar_events.add_rsvpbot_event_to_gcal(event, event_id)
    except calendar_events.KeyfilePathNotSpecifiedError:
      body = strings.ERROR_CALENDAR_ENVS_NOT_SET
    except calendar_events.DateAndTimeNotSuppliedError:
      body = strings.ERROR_DATE_AND_TIME_NOT_SET
    except calendar_events.DurationNotSuppliedError:
      body = strings.ERROR_DURATION_NOT_SET
    else:
      event['calendar_event'] = {}
      event['calendar_event']['id'] = cal_event.get('id')
      event['calendar_event']['html_link'] = cal_event.get('htmlLink')
      body = strings.MSG_ADDED_TO_CALENDAR.format(
          calendar_name=cal_event.get('calendar_name'),
          url=cal_event.get('htmlLink'))

    return RSVPCommandResponse(events, RSVPMessage('stream', body))