mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Remove useless class
This commit is contained in:
parent
aaf2eeb412
commit
6e55e6d2c7
1 changed files with 46 additions and 48 deletions
|
|
@ -11,60 +11,58 @@ from vdirsyncer.storage.http import HttpStorage
|
||||||
from requests import Response
|
from requests import Response
|
||||||
|
|
||||||
|
|
||||||
class TestHttpStorage(object):
|
def test_list(self, monkeypatch):
|
||||||
|
collection_url = 'http://127.0.0.1/calendar/collection.ics'
|
||||||
|
|
||||||
def test_list(self, monkeypatch):
|
items = [
|
||||||
collection_url = 'http://127.0.0.1/calendar/collection.ics'
|
(u'BEGIN:VEVENT\n'
|
||||||
|
u'SUMMARY:Eine Kurzinfo\n'
|
||||||
|
u'DESCRIPTION:Beschreibung des Termines\n'
|
||||||
|
u'END:VEVENT'),
|
||||||
|
(u'BEGIN:VEVENT\n'
|
||||||
|
u'SUMMARY:Eine zweite Kurzinfo\n'
|
||||||
|
u'DESCRIPTION:Beschreibung des anderen Termines\n'
|
||||||
|
u' With an extra line for description\n'
|
||||||
|
u'BEGIN:VALARM\n'
|
||||||
|
u'ACTION:AUDIO\n'
|
||||||
|
u'TRIGGER:19980403T120000\n'
|
||||||
|
u'ATTACH;FMTTYPE=audio/basic:http://host.com/pub/ssbanner.aud\n'
|
||||||
|
u'REPEAT:4\n'
|
||||||
|
u'DURATION:PT1H\n'
|
||||||
|
u'END:VALARM\n'
|
||||||
|
u'END:VEVENT')
|
||||||
|
]
|
||||||
|
|
||||||
items = [
|
responses = [
|
||||||
(u'BEGIN:VEVENT\n'
|
u'\n'.join([u'BEGIN:VCALENDAR'] + items + [u'END:VCALENDAR'])
|
||||||
u'SUMMARY:Eine Kurzinfo\n'
|
] * 2
|
||||||
u'DESCRIPTION:Beschreibung des Termines\n'
|
|
||||||
u'END:VEVENT'),
|
|
||||||
(u'BEGIN:VEVENT\n'
|
|
||||||
u'SUMMARY:Eine zweite Kurzinfo\n'
|
|
||||||
u'DESCRIPTION:Beschreibung des anderen Termines\n'
|
|
||||||
u' With an extra line for description\n'
|
|
||||||
u'BEGIN:VALARM\n'
|
|
||||||
u'ACTION:AUDIO\n'
|
|
||||||
u'TRIGGER:19980403T120000\n'
|
|
||||||
u'ATTACH;FMTTYPE=audio/basic:http://host.com/pub/ssbanner.aud\n'
|
|
||||||
u'REPEAT:4\n'
|
|
||||||
u'DURATION:PT1H\n'
|
|
||||||
u'END:VALARM\n'
|
|
||||||
u'END:VEVENT')
|
|
||||||
]
|
|
||||||
|
|
||||||
responses = [
|
def get(method, url, *a, **kw):
|
||||||
u'\n'.join([u'BEGIN:VCALENDAR'] + items + [u'END:VCALENDAR'])
|
assert method == 'GET'
|
||||||
] * 2
|
assert url == collection_url
|
||||||
|
r = Response()
|
||||||
|
r.status_code = 200
|
||||||
|
assert responses
|
||||||
|
r._content = responses.pop().encode('utf-8')
|
||||||
|
r.encoding = 'utf-8'
|
||||||
|
return r
|
||||||
|
|
||||||
def get(method, url, *a, **kw):
|
monkeypatch.setattr('requests.request', get)
|
||||||
assert method == 'GET'
|
|
||||||
assert url == collection_url
|
|
||||||
r = Response()
|
|
||||||
r.status_code = 200
|
|
||||||
assert responses
|
|
||||||
r._content = responses.pop().encode('utf-8')
|
|
||||||
r.encoding = 'utf-8'
|
|
||||||
return r
|
|
||||||
|
|
||||||
monkeypatch.setattr('requests.request', get)
|
s = HttpStorage(url=collection_url)
|
||||||
|
|
||||||
s = HttpStorage(url=collection_url)
|
found_items = {}
|
||||||
|
|
||||||
found_items = {}
|
for href, etag in s.list():
|
||||||
|
item, etag2 = s.get(href)
|
||||||
|
assert item.uid is None
|
||||||
|
assert etag2 == etag
|
||||||
|
found_items[item.raw.strip()] = href
|
||||||
|
|
||||||
for href, etag in s.list():
|
assert set(found_items) == set(items)
|
||||||
item, etag2 = s.get(href)
|
|
||||||
assert item.uid is None
|
|
||||||
assert etag2 == etag
|
|
||||||
found_items[item.raw.strip()] = href
|
|
||||||
|
|
||||||
assert set(found_items) == set(items)
|
for href, etag in s.list():
|
||||||
|
item, etag2 = s.get(href)
|
||||||
for href, etag in s.list():
|
assert item.uid is None
|
||||||
item, etag2 = s.get(href)
|
assert etag2 == etag
|
||||||
assert item.uid is None
|
assert found_items[item.raw.strip()] == href
|
||||||
assert etag2 == etag
|
|
||||||
assert found_items[item.raw.strip()] == href
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue