Fix some tests
This commit is contained in:
parent
b1ce0fcfd3
commit
459b02c9a4
@ -23,8 +23,8 @@ BEGIN:VEVENT
|
|||||||
CREATED:20130902T150157Z
|
CREATED:20130902T150157Z
|
||||||
LAST-MODIFIED:20130902T150158Z
|
LAST-MODIFIED:20130902T150158Z
|
||||||
DTSTAMP:20130902T150158Z
|
DTSTAMP:20130902T150158Z
|
||||||
UID:02805f81-4cc2-4d68-8d39-72768ffa02d9
|
UID:event
|
||||||
SUMMARY:Nouvel évènement
|
SUMMARY:Event
|
||||||
DTSTART;TZID=Europe/Paris:20130902T180000
|
DTSTART;TZID=Europe/Paris:20130902T180000
|
||||||
DTEND;TZID=Europe/Paris:20130902T190000
|
DTEND;TZID=Europe/Paris:20130902T190000
|
||||||
END:VEVENT
|
END:VEVENT
|
@ -5,7 +5,7 @@ BEGIN:VTODO
|
|||||||
CREATED:20130903T091105Z
|
CREATED:20130903T091105Z
|
||||||
LAST-MODIFIED:20130903T091108Z
|
LAST-MODIFIED:20130903T091108Z
|
||||||
DTSTAMP:20130903T091108Z
|
DTSTAMP:20130903T091108Z
|
||||||
UID:40f8cf9b-0e62-4624-89a2-24c5e68850f5
|
UID:todo
|
||||||
SUMMARY:Nouvelle tâche
|
SUMMARY:Todo
|
||||||
END:VTODO
|
END:VTODO
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
@ -36,7 +36,7 @@ class BaseRequests(object):
|
|||||||
"""Tests with simple requests."""
|
"""Tests with simple requests."""
|
||||||
|
|
||||||
def test_root(self):
|
def test_root(self):
|
||||||
"""Test a GET request at "/"."""
|
"""GET request at "/"."""
|
||||||
status, headers, answer = self.request("GET", "/")
|
status, headers, answer = self.request("GET", "/")
|
||||||
assert status == 200
|
assert status == 200
|
||||||
assert "Radicale works!" in answer
|
assert "Radicale works!" in answer
|
||||||
@ -47,37 +47,38 @@ class BaseRequests(object):
|
|||||||
assert "END:VCALENDAR" in answer
|
assert "END:VCALENDAR" in answer
|
||||||
assert "PRODID:-//Radicale//NONSGML Radicale Server//EN" in answer
|
assert "PRODID:-//Radicale//NONSGML Radicale Server//EN" in answer
|
||||||
|
|
||||||
def test_add_event_todo(self):
|
def test_add_event(self):
|
||||||
"""Tests the add of an event and todo."""
|
"""Add an event."""
|
||||||
self.request("GET", "/calendar.ics/")
|
self.request("GET", "/calendar.ics/")
|
||||||
#VEVENT test
|
event = get_file_content("event.ics")
|
||||||
event = get_file_content("put.ics")
|
path = "/calendar.ics/event.ics"
|
||||||
path = "/calendar.ics/02805f81-4cc2-4d68-8d39-72768ffa02d9.ics"
|
|
||||||
status, headers, answer = self.request("PUT", path, event)
|
status, headers, answer = self.request("PUT", path, event)
|
||||||
assert status == 201
|
assert status == 201
|
||||||
assert "ETag" in headers.keys()
|
|
||||||
status, headers, answer = self.request("GET", path)
|
status, headers, answer = self.request("GET", path)
|
||||||
|
assert "ETag" in headers.keys()
|
||||||
assert status == 200
|
assert status == 200
|
||||||
assert "VEVENT" in answer
|
assert "VEVENT" in answer
|
||||||
assert b"Nouvel \xc3\xa9v\xc3\xa8nement".decode("utf-8") in answer
|
assert "Event" in answer
|
||||||
assert "UID:02805f81-4cc2-4d68-8d39-72768ffa02d9" in answer
|
assert "UID:event" in answer
|
||||||
# VTODO test
|
|
||||||
todo = get_file_content("putvtodo.ics")
|
def test_add_todo(self):
|
||||||
path = "/calendar.ics/40f8cf9b-0e62-4624-89a2-24c5e68850f5.ics"
|
"""Add a todo."""
|
||||||
|
self.request("GET", "/calendar.ics/")
|
||||||
|
todo = get_file_content("todo.ics")
|
||||||
|
path = "/calendar.ics/todo.ics"
|
||||||
status, headers, answer = self.request("PUT", path, todo)
|
status, headers, answer = self.request("PUT", path, todo)
|
||||||
assert status == 201
|
assert status == 201
|
||||||
assert "ETag" in headers.keys()
|
|
||||||
status, headers, answer = self.request("GET", path)
|
status, headers, answer = self.request("GET", path)
|
||||||
|
assert "ETag" in headers.keys()
|
||||||
assert "VTODO" in answer
|
assert "VTODO" in answer
|
||||||
assert b"Nouvelle t\xc3\xa2che".decode("utf-8") in answer
|
assert "Todo" in answer
|
||||||
assert "UID:40f8cf9b-0e62-4624-89a2-24c5e68850f5" in answer
|
assert "UID:todo" in answer
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
"""Tests the deletion of an event"""
|
"""Delete an event."""
|
||||||
self.request("GET", "/calendar.ics/")
|
self.request("GET", "/calendar.ics/")
|
||||||
# Adds a VEVENT to be deleted
|
event = get_file_content("event.ics")
|
||||||
event = get_file_content("put.ics")
|
path = "/calendar.ics/event.ics"
|
||||||
path = "/calendar.ics/02805f81-4cc2-4d68-8d39-72768ffa02d9.ics"
|
|
||||||
status, headers, answer = self.request("PUT", path, event)
|
status, headers, answer = self.request("PUT", path, event)
|
||||||
# Then we send a DELETE request
|
# Then we send a DELETE request
|
||||||
status, headers, answer = self.request("DELETE", path)
|
status, headers, answer = self.request("DELETE", path)
|
||||||
@ -154,4 +155,4 @@ class TestCustomStorageSystem(BaseRequests, BaseTest):
|
|||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
"""Teardown function for each test."""
|
"""Teardown function for each test."""
|
||||||
shutil.rmtree(self.colpath)
|
shutil.rmtree(self.colpath)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user