mirror of
https://github.com/status-im/cabot.git
synced 2025-02-25 02:45:16 +00:00
Add tests for recurring calendar rotas
This commit is contained in:
parent
c16dce35b3
commit
77df4fa676
57
cabot/cabotapp/tests/fixtures/recurring_response.ics
vendored
Normal file
57
cabot/cabotapp/tests/fixtures/recurring_response.ics
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
BEGIN:VCALENDAR
|
||||
PRODID:-//Google Inc//Google Calendar 70.9054//EN
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
METHOD:PUBLISH
|
||||
X-WR-CALNAME:Cabot Rota
|
||||
X-WR-TIMEZONE:America/New_York
|
||||
X-WR-CALDESC:
|
||||
BEGIN:VTIMEZONE
|
||||
TZID:America/New_York
|
||||
X-LIC-LOCATION:America/New_York
|
||||
BEGIN:DAYLIGHT
|
||||
TZOFFSETFROM:-0500
|
||||
TZOFFSETTO:-0400
|
||||
TZNAME:EDT
|
||||
DTSTART:19700308T020000
|
||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
|
||||
END:DAYLIGHT
|
||||
BEGIN:STANDARD
|
||||
TZOFFSETFROM:-0400
|
||||
TZOFFSETTO:-0500
|
||||
TZNAME:EST
|
||||
DTSTART:19701101T020000
|
||||
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
|
||||
END:STANDARD
|
||||
END:VTIMEZONE
|
||||
BEGIN:VEVENT
|
||||
DTSTART;TZID=America/New_York:20161129T080000
|
||||
DTEND;TZID=America/New_York:20161130T080000
|
||||
RRULE:FREQ=DAILY;INTERVAL=2
|
||||
DTSTAMP:20161128T214445Z
|
||||
UID:mep8lmf2s1lhmmm366c6rhhers@google.com
|
||||
CREATED:20161128T204255Z
|
||||
DESCRIPTION:
|
||||
LAST-MODIFIED:20161128T204255Z
|
||||
LOCATION:
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:foo
|
||||
TRANSP:OPAQUE
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTART;TZID=America/New_York:20161128T080000
|
||||
DTEND;TZID=America/New_York:20161129T080000
|
||||
RRULE:FREQ=DAILY;INTERVAL=2
|
||||
DTSTAMP:20161128T214445Z
|
||||
UID:s4ftq5jd98cuubmbous3mgst5c@google.com
|
||||
CREATED:20161128T203907Z
|
||||
DESCRIPTION:
|
||||
LAST-MODIFIED:20161128T203947Z
|
||||
LOCATION:
|
||||
SEQUENCE:1
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:bar
|
||||
TRANSP:OPAQUE
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
@ -169,6 +169,11 @@ def fake_gcal_response(*args, **kwargs):
|
||||
resp.status_code = 200
|
||||
return resp
|
||||
|
||||
def fake_recurring_response(*args, **kwargs):
|
||||
resp = Mock()
|
||||
resp.content = get_content('recurring_response.ics')
|
||||
resp.status_code = 200
|
||||
return resp
|
||||
|
||||
def throws_timeout(*args, **kwargs):
|
||||
raise requests.RequestException(u'фиктивная ошибка innit')
|
||||
@ -433,6 +438,20 @@ class TestDutyRota(LocalTestCase):
|
||||
events = get_events()
|
||||
self.assertEqual(events[0]['summary'], 'troels')
|
||||
|
||||
@patch('cabot.cabotapp.models.requests.get', fake_recurring_response)
|
||||
def test_duty_rota_recurring(self):
|
||||
events = get_events()
|
||||
events.sort(key=lambda ev: ev['start'])
|
||||
curr_summ = events[0]['summary'];
|
||||
self.assertTrue(curr_summ == 'foo' or curr_summ == 'bar')
|
||||
for i in range(0, 60):
|
||||
self.assertEqual(events[i]['summary'], curr_summ)
|
||||
if(curr_summ == 'foo'):
|
||||
curr_summ = 'bar'
|
||||
else:
|
||||
curr_summ = 'foo'
|
||||
|
||||
|
||||
class TestWebInterface(LocalTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user