258 |
258 |
agenda.kind = kind
|
259 |
259 |
agenda.save()
|
260 |
260 |
app.get('/api/agenda/%s/subscription/%s/' % (agenda.slug, subscription.pk), status=404)
|
|
261 |
|
|
262 |
|
|
263 |
def test_api_delete_subscription(app, user):
|
|
264 |
agenda = Agenda.objects.create(label='Foo bar', kind='events')
|
|
265 |
subscription = Subscription.objects.create(
|
|
266 |
agenda=agenda,
|
|
267 |
user_external_id='xxx',
|
|
268 |
user_first_name='Foo',
|
|
269 |
user_last_name='BAR',
|
|
270 |
user_email='foo@bar.com',
|
|
271 |
user_phone_number='06',
|
|
272 |
extra_data={'foo': 'bar'},
|
|
273 |
date_start=datetime.date(year=2021, month=9, day=1),
|
|
274 |
date_end=datetime.date(year=2021, month=10, day=1),
|
|
275 |
)
|
|
276 |
other_agenda = Agenda.objects.create(label='Foo bar', kind='events')
|
|
277 |
other_subscription = Subscription.objects.create(
|
|
278 |
agenda=other_agenda,
|
|
279 |
user_external_id='xxx',
|
|
280 |
date_start=datetime.date(year=2021, month=9, day=1),
|
|
281 |
date_end=datetime.date(year=2021, month=10, day=1),
|
|
282 |
)
|
|
283 |
|
|
284 |
resp = app.delete('/api/agenda/%s/subscription/%s/' % (agenda.slug, subscription.pk), status=401)
|
|
285 |
|
|
286 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
287 |
|
|
288 |
app.delete('/api/agenda/%s/subscription/%s/' % (agenda.slug, other_subscription.pk), status=404)
|
|
289 |
app.delete('/api/agenda/%s/subscription/%s/' % (agenda.slug, 0), status=404)
|
|
290 |
app.delete('/api/agenda/%s/subscription/%s/' % ('unknown', subscription.pk), status=404)
|
|
291 |
for kind in ['meetings', 'virtual']:
|
|
292 |
agenda.kind = kind
|
|
293 |
agenda.save()
|
|
294 |
app.delete('/api/agenda/%s/subscription/%s/' % (agenda.slug, subscription.pk), status=404)
|
|
295 |
|
|
296 |
agenda.kind = 'events'
|
|
297 |
agenda.save()
|
|
298 |
|
|
299 |
resp = app.delete('/api/agenda/%s/subscription/%s/' % (agenda.slug, subscription.pk))
|
|
300 |
assert resp.json['err'] == 0
|
|
301 |
assert Subscription.objects.filter(pk=subscription.pk).exists() is False
|
261 |
|
-
|