(monkeypatch)
| 9 | |
| 10 | |
| 11 | def test_list(monkeypatch): |
| 12 | collection_url = 'http://127.0.0.1/calendar/collection.ics' |
| 13 | |
| 14 | items = [ |
| 15 | ('BEGIN:VEVENT\n' |
| 16 | 'SUMMARY:Eine Kurzinfo\n' |
| 17 | 'DESCRIPTION:Beschreibung des Termines\n' |
| 18 | 'END:VEVENT'), |
| 19 | ('BEGIN:VEVENT\n' |
| 20 | 'SUMMARY:Eine zweite Küèrzinfo\n' |
| 21 | 'DESCRIPTION:Beschreibung des anderen Termines\n' |
| 22 | 'BEGIN:VALARM\n' |
| 23 | 'ACTION:AUDIO\n' |
| 24 | 'TRIGGER:19980403T120000\n' |
| 25 | 'ATTACH;FMTTYPE=audio/basic:http://host.com/pub/ssbanner.aud\n' |
| 26 | 'REPEAT:4\n' |
| 27 | 'DURATION:PT1H\n' |
| 28 | 'END:VALARM\n' |
| 29 | 'END:VEVENT') |
| 30 | ] |
| 31 | |
| 32 | responses = [ |
| 33 | '\n'.join(['BEGIN:VCALENDAR'] + items + ['END:VCALENDAR']) |
| 34 | ] * 2 |
| 35 | |
| 36 | def get(self, method, url, *a, **kw): |
| 37 | assert method == 'GET' |
| 38 | assert url == collection_url |
| 39 | r = Response() |
| 40 | r.status_code = 200 |
| 41 | assert responses |
| 42 | r._content = responses.pop().encode('utf-8') |
| 43 | r.headers['Content-Type'] = 'text/calendar' |
| 44 | r.encoding = 'ISO-8859-1' |
| 45 | return r |
| 46 | |
| 47 | monkeypatch.setattr('requests.sessions.Session.request', get) |
| 48 | |
| 49 | s = HttpStorage(url=collection_url) |
| 50 | |
| 51 | found_items = {} |
| 52 | |
| 53 | for href, etag in s.list(): |
| 54 | item, etag2 = s.get(href) |
| 55 | assert item.uid is not None |
| 56 | assert etag2 == etag |
| 57 | found_items[normalize_item(item)] = href |
| 58 | |
| 59 | expected = {normalize_item('BEGIN:VCALENDAR\n' + x + '\nEND:VCALENDAR') |
| 60 | for x in items} |
| 61 | |
| 62 | assert set(found_items) == expected |
| 63 | |
| 64 | for href, etag in s.list(): |
| 65 | item, etag2 = s.get(href) |
| 66 | assert item.uid is not None |
| 67 | assert etag2 == etag |
| 68 | assert found_items[normalize_item(item)] == href |
nothing calls this directly
no test coverage detected