|
@@ -6,11 +6,14 @@ from caldav.lib.error import AuthorizationError
|
6
|
6
|
from nose.tools import eq_, ok_
|
7
|
7
|
import requests
|
8
|
8
|
from requests.exceptions import ConnectionError
|
|
9
|
+from sqlalchemy.orm.exc import NoResultFound
|
9
|
10
|
|
|
11
|
+from tracim.config.app_cfg import daemons
|
10
|
12
|
from tracim.lib.workspace import WorkspaceApi
|
11
|
13
|
from tracim.model import DBSession
|
12
|
14
|
from tracim.tests import TestCalendar as BaseTestCalendar
|
13
|
15
|
from tracim.model.auth import User
|
|
16
|
+from tracim.model.data import Content
|
14
|
17
|
|
15
|
18
|
|
16
|
19
|
class TestCalendar(BaseTestCalendar):
|
|
@@ -166,3 +169,50 @@ class TestCalendar(BaseTestCalendar):
|
166
|
169
|
ok_(False, 'User can\'t access unright workspace calendar')
|
167
|
170
|
except AuthorizationError:
|
168
|
171
|
ok_(True, 'User should not access unright workspace calendar')
|
|
172
|
+
|
|
173
|
+ def test_func__event_create__ok__nominal_case(self):
|
|
174
|
+ lawrence = DBSession.query(User).filter(
|
|
175
|
+ User.email == 'lawrence-not-real-email@fsf.local'
|
|
176
|
+ ).one()
|
|
177
|
+ radicale_base_url = self._get_base_url()
|
|
178
|
+ client = caldav.DAVClient(
|
|
179
|
+ radicale_base_url,
|
|
180
|
+ username='lawrence-not-real-email@fsf.local',
|
|
181
|
+ password='foobarbaz'
|
|
182
|
+ )
|
|
183
|
+ user_calendar_url = self._get_user_calendar_url(lawrence.user_id)
|
|
184
|
+ user_calendar = caldav.Calendar(
|
|
185
|
+ parent=client,
|
|
186
|
+ client=client,
|
|
187
|
+ url=user_calendar_url
|
|
188
|
+ )
|
|
189
|
+
|
|
190
|
+ event_ics = """BEGIN:VCALENDAR
|
|
191
|
+VERSION:2.0
|
|
192
|
+PRODID:-//Example Corp.//CalDAV Client//EN
|
|
193
|
+BEGIN:VEVENT
|
|
194
|
+UID:1234567890
|
|
195
|
+DTSTAMP:20100510T182145Z
|
|
196
|
+DTSTART:20100512T170000Z
|
|
197
|
+DTEND:20100512T180000Z
|
|
198
|
+SUMMARY:This is an event
|
|
199
|
+LOCATION:Here
|
|
200
|
+END:VEVENT
|
|
201
|
+END:VCALENDAR
|
|
202
|
+"""
|
|
203
|
+ user_calendar.add_event(event_ics)
|
|
204
|
+ user_calendar.save()
|
|
205
|
+
|
|
206
|
+ daemons.execute_in_thread('radicale', lambda: transaction.commit())
|
|
207
|
+
|
|
208
|
+ try:
|
|
209
|
+ event = DBSession.query(Content).filter(
|
|
210
|
+ Content.label == 'This is an event'
|
|
211
|
+ ).one()
|
|
212
|
+ except NoResultFound:
|
|
213
|
+ ok_(False, 'Content record should exist for '
|
|
214
|
+ '"This is an event" label')
|
|
215
|
+
|
|
216
|
+ eq_(event.properties['location'], 'Here')
|
|
217
|
+ eq_(event.properties['start'], '2010-05-12 18:00:00+0000')
|
|
218
|
+ eq_(event.properties['end'], '2010-05-12 17:00:00+0000')
|