コード例 #1
0
 def test_get_events_with_attendees_returns_empty_list_for_events_with_no_attendees(self):
     events = [
         {'summary': 'Empty event with no attendees'},
         {'summary': 'Empty event with no attendees'}
     ]
     calendar_google = CalendarGoogle(config, '')
     self.assertEquals(calendar_google.get_events_with_attendees(events), [])
コード例 #2
0
 def test_get_events_with_attendees_returns_proper_response_with_attended_meetings_only(
         self):
     events = [{'summary': 'Empty event with no attendees'}]
     proper_event = {'summary': 'Event with attendees', 'attendees': True}
     events.append(proper_event)
     calendar_google = CalendarGoogle(config, '')
     self.assertEquals(calendar_google.get_events_with_attendees(events),
                       [proper_event])
コード例 #3
0
 def test_get_events_with_attendees_returns_proper_response_with_attended_meetings_only(self):
     events = [
         {'summary': 'Empty event with no attendees'}
     ]
     proper_event = {'summary': 'Event with attendees', 'attendees': True}
     events.append(proper_event)
     calendar_google = CalendarGoogle(config, '')
     self.assertEquals(calendar_google.get_events_with_attendees(events), [proper_event])
コード例 #4
0
 def test_get_events_with_attendees_returns_empty_list_for_events_with_no_attendees(
         self):
     events = [{
         'summary': 'Empty event with no attendees'
     }, {
         'summary': 'Empty event with no attendees'
     }]
     calendar_google = CalendarGoogle(config, '')
     self.assertEquals(calendar_google.get_events_with_attendees(events),
                       [])
コード例 #5
0
 def test_verify_dates_returns_false_for_missing_end_date(self):
     event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': ''
         },
         'end': {}
     }
     self.assertFalse(CalendarGoogle.verify_dates(event))
コード例 #6
0
 def test_verify_dates_returns_false_for_missing_end_date(self):
     event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': ''
         },
         'end': {}
     }
     self.assertFalse(CalendarGoogle.verify_dates(event))
コード例 #7
0
 def test_get_accepted_events_returns_empty_list_for_not_accepted_meeting(self):
     events = [
         {
             'summary': 'Event with attendees',
             'attendees': [
                 {'responseStatus': 'pending', 'self': True}
             ]
         }
     ]
     self.assertEquals(CalendarGoogle.get_accepted_events(events), [])
コード例 #8
0
 def test_get_accepted_events_returns_empty_list_for_not_accepted_meeting(
         self):
     events = [{
         'summary': 'Event with attendees',
         'attendees': [{
             'responseStatus': 'pending',
             'self': True
         }]
     }]
     self.assertEquals(CalendarGoogle.get_accepted_events(events), [])
コード例 #9
0
 def test_verify_dates_returns_true_for_valid_input(self):
     event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': '1970-01-01'
         },
         'end': {
             'dateTime': '1970-01-01'
         }
     }
     self.assertTrue(CalendarGoogle.verify_dates(event))
コード例 #10
0
 def test_verify_dates_returns_false_for_different_start_and_end_dates(self):
     event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': '1970-01-02'
         },
         'end': {
             'dateTime': '1970-01-01'
         }
     }
     self.assertFalse(CalendarGoogle.verify_dates(event))
コード例 #11
0
 def test_verify_dates_returns_true_for_valid_input(self):
     event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': '1970-01-01'
         },
         'end': {
             'dateTime': '1970-01-01'
         }
     }
     self.assertTrue(CalendarGoogle.verify_dates(event))
コード例 #12
0
 def test_verify_dates_returns_false_for_different_start_and_end_dates(
         self):
     event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': '1970-01-02'
         },
         'end': {
             'dateTime': '1970-01-01'
         }
     }
     self.assertFalse(CalendarGoogle.verify_dates(event))
コード例 #13
0
 def test_get_events_with_proper_dates(self):
     bad_event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': '1970-01-02'
         },
         'end': {
             'dateTime': '1970-01-01'
         }
     }
     good_event = {
         'summary': 'Valid summary',
         'start': {
             'dateTime': '1970-01-01'
         },
         'end': {
             'dateTime': '1970-01-01'
         }
     }
     events = [bad_event, good_event]
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_events_with_proper_dates(events),
                       [good_event])
コード例 #14
0
 def test_get_accepted_events_returns_proper_response(self):
     events = [
         {
             'summary': 'Event with attendees',
             'attendees': [
                 {'responseStatus': 'pending', 'self': True}
             ]
         }
     ]
     accepted_event = {
         'summary': 'Accepted event with attendees',
         'attendees': [
             {'responseStatus': 'accepted', 'self': True}
         ]
     }
     events.append(accepted_event)
     self.assertEquals(CalendarGoogle.get_accepted_events(events), [accepted_event])
コード例 #15
0
 def test_get_accepted_events_returns_proper_response(self):
     events = [{
         'summary': 'Event with attendees',
         'attendees': [{
             'responseStatus': 'pending',
             'self': True
         }]
     }]
     accepted_event = {
         'summary': 'Accepted event with attendees',
         'attendees': [{
             'responseStatus': 'accepted',
             'self': True
         }]
     }
     events.append(accepted_event)
     self.assertEquals(CalendarGoogle.get_accepted_events(events),
                       [accepted_event])
コード例 #16
0
ファイル: run.py プロジェクト: pawel-lewtak/economic-py
def get_calendar_provider(config, src_path):
    """
    Return calendar object based on provider set in config file.

    :param config: list of tuples
    :param src_path: path to current directory
    :return: Calendar|OutlookCalendar
    """
    economic_config = dict(config.items('Economic'))
    if 'Google' == economic_config['calendar_provider']:
        calendar = CalendarGoogle(config.items('Google'), src_path)
    elif 'Office365' == economic_config['calendar_provider']:
        calendar = CalendarOutlook(config.items('Office365'))
    else:
        print("Unsupported calendar provider")
        sys.exit(1)

    return calendar
コード例 #17
0
 def test_get_project_id_returns_default_project_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_project_id('description'), 20)
コード例 #18
0
 def test_get_project_id_returns_extracted_project_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_project_id('#eConomic: 123'), 123)
コード例 #19
0
 def test_get_activity_id_returns_error_on_config_missing(self):
     config_copy = copy.copy(config)
     config_copy.append(('activity_id_pattern', ''))
     cal = CalendarGoogle(config_copy, '')
     self.assertEquals(cal.get_activity_id('description'), -1)
コード例 #20
0
 def test_ignore_event_returns_true(self):
     cal = CalendarGoogle(config, '')
     event = {
         'summary': 'this contains ignored word'
     }
     self.assertTrue(cal.ignore_event(event))
コード例 #21
0
 def test_get_activity_id_returns_default_activity_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_activity_id('description'), 10)
コード例 #22
0
 def test_get_activity_id_returns_exctracted_activity_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_activity_id('#activitY: 234'), 234)
コード例 #23
0
 def test_get_events_with_proper_dates(self):
     bad_event = {'summary': 'Valid summary', 'start': {'dateTime': '1970-01-02'}, 'end': {'dateTime': '1970-01-01'}}
     good_event = {'summary': 'Valid summary', 'start': {'dateTime': '1970-01-01'}, 'end': {'dateTime': '1970-01-01'}}
     events = [bad_event, good_event]
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_events_with_proper_dates(events), [good_event])
コード例 #24
0
 def test_get_activity_id_returns_default_activity_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_activity_id('description'), 10)
コード例 #25
0
 def test_get_activity_id_returns_error_on_config_missing(self):
     config_copy = copy.copy(config)
     config_copy.append(('activity_id_pattern', ''))
     cal = CalendarGoogle(config_copy, '')
     self.assertEquals(cal.get_activity_id('description'), -1)
コード例 #26
0
 def test_get_project_id_returns_extracted_project_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_project_id('#eConomic: 123'), 123)
コード例 #27
0
 def test_get_project_id_returns_default_project_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_project_id('description'), 20)
コード例 #28
0
 def test_skip_ignored_events(self):
     ignored_event = {'summary': 'this contains ignored word'}
     proper_event = {'summary': 'Valid summary'}
     events = [ignored_event, proper_event]
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.skip_ignored_events(events), [proper_event])
コード例 #29
0
 def test_ignore_event_returns_true(self):
     cal = CalendarGoogle(config, '')
     event = {'summary': 'this contains ignored word'}
     self.assertTrue(cal.ignore_event(event))
コード例 #30
0
 def test_get_activity_id_returns_exctracted_activity_id(self):
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.get_activity_id('#activitY: 234'), 234)
コード例 #31
0
 def test_skip_ignored_events(self):
     ignored_event = {'summary': 'this contains ignored word'}
     proper_event = {'summary': 'Valid summary'}
     events = [ignored_event, proper_event]
     cal = CalendarGoogle(config, '')
     self.assertEquals(cal.skip_ignored_events(events), [proper_event])
コード例 #32
0
 def test_ignore_event_returns_false(self):
     cal = CalendarGoogle(config, '')
     event = {'summary': 'valid summary'}
     self.assertFalse(cal.ignore_event(event))
コード例 #33
0
 def test_ignore_event_returns_false(self):
     cal = CalendarGoogle(config, '')
     event = {
         'summary': 'valid summary'
     }
     self.assertFalse(cal.ignore_event(event))