287 |
287 |
|
288 |
288 |
# not found
|
289 |
289 |
with pytest.raises(AgendaPricingNotFound):
|
290 |
|
AgendaPricing.get_agenda_pricing(agenda=agenda, start_date=start_date)
|
|
290 |
AgendaPricing.get_agenda_pricing(
|
|
291 |
agenda=agenda,
|
|
292 |
start_date=start_date,
|
|
293 |
flat_fee_schedule=False,
|
|
294 |
)
|
|
295 |
with pytest.raises(AgendaPricingNotFound):
|
|
296 |
AgendaPricing.get_agenda_pricing(
|
|
297 |
agenda=agenda,
|
|
298 |
start_date=start_date,
|
|
299 |
flat_fee_schedule=True,
|
|
300 |
)
|
291 |
301 |
|
292 |
302 |
# ok
|
293 |
303 |
agenda_pricing = AgendaPricing.objects.create(
|
294 |
304 |
pricing=pricing,
|
295 |
305 |
date_start=datetime.date(year=2021, month=9, day=1),
|
296 |
306 |
date_end=datetime.date(year=2021, month=10, day=1),
|
|
307 |
flat_fee_schedule=False,
|
297 |
308 |
)
|
298 |
309 |
agenda_pricing.agendas.add(agenda)
|
299 |
|
assert AgendaPricing.get_agenda_pricing(agenda=agenda, start_date=start_date) == agenda_pricing
|
|
310 |
agenda_pricing2 = AgendaPricing.objects.create(
|
|
311 |
pricing=pricing,
|
|
312 |
date_start=datetime.date(year=2021, month=9, day=1),
|
|
313 |
date_end=datetime.date(year=2021, month=10, day=1),
|
|
314 |
flat_fee_schedule=True,
|
|
315 |
)
|
|
316 |
agenda_pricing2.agendas.add(agenda)
|
|
317 |
assert (
|
|
318 |
AgendaPricing.get_agenda_pricing(
|
|
319 |
agenda=agenda,
|
|
320 |
start_date=start_date,
|
|
321 |
flat_fee_schedule=False,
|
|
322 |
)
|
|
323 |
== agenda_pricing
|
|
324 |
)
|
|
325 |
assert (
|
|
326 |
AgendaPricing.get_agenda_pricing(
|
|
327 |
agenda=agenda,
|
|
328 |
start_date=start_date,
|
|
329 |
flat_fee_schedule=True,
|
|
330 |
)
|
|
331 |
== agenda_pricing2
|
|
332 |
)
|
300 |
333 |
|
301 |
334 |
# more than one matching
|
302 |
335 |
agenda_pricing = AgendaPricing.objects.create(
|
303 |
336 |
pricing=pricing,
|
304 |
337 |
date_start=datetime.date(year=2021, month=9, day=14),
|
305 |
338 |
date_end=datetime.date(year=2021, month=9, day=16),
|
|
339 |
flat_fee_schedule=False,
|
306 |
340 |
)
|
307 |
341 |
agenda_pricing.agendas.add(agenda)
|
|
342 |
agenda_pricing2 = AgendaPricing.objects.create(
|
|
343 |
pricing=pricing,
|
|
344 |
date_start=datetime.date(year=2021, month=9, day=14),
|
|
345 |
date_end=datetime.date(year=2021, month=9, day=16),
|
|
346 |
flat_fee_schedule=True,
|
|
347 |
)
|
|
348 |
agenda_pricing2.agendas.add(agenda)
|
308 |
349 |
with pytest.raises(AgendaPricingNotFound):
|
309 |
|
AgendaPricing.get_agenda_pricing(agenda=agenda, start_date=start_date)
|
|
350 |
AgendaPricing.get_agenda_pricing(
|
|
351 |
agenda=agenda,
|
|
352 |
start_date=start_date,
|
|
353 |
flat_fee_schedule=False,
|
|
354 |
)
|
|
355 |
AgendaPricing.get_agenda_pricing(
|
|
356 |
agenda=agenda,
|
|
357 |
start_date=start_date,
|
|
358 |
flat_fee_schedule=True,
|
|
359 |
)
|
310 |
360 |
|
311 |
361 |
|
312 |
362 |
@pytest.mark.parametrize(
|
313 |
|
'event_date, found',
|
|
363 |
'start_date, found',
|
314 |
364 |
[
|
315 |
365 |
# just before first day
|
316 |
366 |
((2021, 8, 31), False),
|
... | ... | |
322 |
372 |
((2021, 10, 1), False),
|
323 |
373 |
],
|
324 |
374 |
)
|
325 |
|
def test_get_agenda_pricing_event_date(event_date, found):
|
|
375 |
def test_get_agenda_pricing_start_date(start_date, found):
|
326 |
376 |
agenda = Agenda.objects.create(label='Foo bar')
|
327 |
377 |
pricing = Pricing.objects.create(label='Foo bar')
|
328 |
378 |
agenda_pricing = AgendaPricing.objects.create(
|
329 |
379 |
pricing=pricing,
|
330 |
380 |
date_start=datetime.date(year=2021, month=9, day=1),
|
331 |
381 |
date_end=datetime.date(year=2021, month=10, day=1),
|
|
382 |
flat_fee_schedule=False,
|
332 |
383 |
)
|
333 |
384 |
agenda_pricing.agendas.add(agenda)
|
334 |
|
start_date = datetime.date(*event_date)
|
|
385 |
agenda_pricing2 = AgendaPricing.objects.create(
|
|
386 |
pricing=pricing,
|
|
387 |
date_start=datetime.date(year=2021, month=9, day=1),
|
|
388 |
date_end=datetime.date(year=2021, month=10, day=1),
|
|
389 |
flat_fee_schedule=True,
|
|
390 |
)
|
|
391 |
agenda_pricing2.agendas.add(agenda)
|
|
392 |
start_date = datetime.date(*start_date)
|
335 |
393 |
if found:
|
336 |
|
assert AgendaPricing.get_agenda_pricing(agenda=agenda, start_date=start_date) == agenda_pricing
|
|
394 |
assert (
|
|
395 |
AgendaPricing.get_agenda_pricing(
|
|
396 |
agenda=agenda,
|
|
397 |
start_date=start_date,
|
|
398 |
flat_fee_schedule=False,
|
|
399 |
)
|
|
400 |
== agenda_pricing
|
|
401 |
)
|
|
402 |
assert (
|
|
403 |
AgendaPricing.get_agenda_pricing(
|
|
404 |
agenda=agenda,
|
|
405 |
start_date=start_date,
|
|
406 |
flat_fee_schedule=True,
|
|
407 |
)
|
|
408 |
== agenda_pricing2
|
|
409 |
)
|
337 |
410 |
else:
|
338 |
411 |
with pytest.raises(AgendaPricingNotFound):
|
339 |
|
AgendaPricing.get_agenda_pricing(agenda=agenda, start_date=start_date)
|
|
412 |
AgendaPricing.get_agenda_pricing(
|
|
413 |
agenda=agenda,
|
|
414 |
start_date=start_date,
|
|
415 |
flat_fee_schedule=False,
|
|
416 |
)
|
|
417 |
AgendaPricing.get_agenda_pricing(
|
|
418 |
agenda=agenda,
|
|
419 |
start_date=start_date,
|
|
420 |
flat_fee_schedule=True,
|
|
421 |
)
|
340 |
422 |
|
341 |
423 |
|
342 |
424 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
343 |
|
-
|