29 |
29 |
resp = app.get('/manage/pricing/agendas/')
|
30 |
30 |
resp = resp.click(href='/manage/pricing/agenda/%s/' % agenda.pk)
|
31 |
31 |
resp = resp.click('New pricing')
|
|
32 |
# first pricing, starts on today
|
|
33 |
assert resp.form['date_start'].value == datetime.date.today().strftime('%Y-%m-%d')
|
32 |
34 |
resp.form['pricing'] = pricing.pk
|
33 |
35 |
resp.form['date_start'] = '2021-09-01'
|
34 |
36 |
resp.form['date_end'] = '2021-09-01'
|
... | ... | |
44 |
46 |
assert agenda_pricing.date_end == datetime.date(2022, 9, 1)
|
45 |
47 |
|
46 |
48 |
resp = app.get('/manage/pricing/agenda/%s/pricing/add/' % agenda.pk)
|
|
49 |
# starts on last date_end
|
|
50 |
assert resp.form['date_start'].value == '2022-09-01'
|
47 |
51 |
resp.form['pricing'] = pricing.pk
|
48 |
52 |
resp.form['date_start'] = '2021-11-01'
|
49 |
53 |
resp.form['date_end'] = '2022-11-01'
|
50 |
54 |
resp = resp.form.submit()
|
51 |
55 |
assert resp.context['form'].errors['__all__'] == ['Pricing overlaps existing pricings.']
|
52 |
|
resp.form['date_start'] = '2022-09-01'
|
53 |
|
resp.form['date_end'] = '2023-09-01'
|
|
56 |
resp.form['date_start'] = '2020-09-01'
|
|
57 |
resp.form['date_end'] = '2021-09-01'
|
54 |
58 |
resp = resp.form.submit()
|
55 |
59 |
agenda_pricing = AgendaPricing.objects.latest('pk')
|
56 |
60 |
assert agenda_pricing.pricing == pricing
|
57 |
61 |
assert agenda_pricing.agenda == agenda
|
58 |
|
assert agenda_pricing.date_start == datetime.date(2022, 9, 1)
|
59 |
|
assert agenda_pricing.date_end == datetime.date(2023, 9, 1)
|
|
62 |
assert agenda_pricing.date_start == datetime.date(2020, 9, 1)
|
|
63 |
assert agenda_pricing.date_end == datetime.date(2021, 9, 1)
|
60 |
64 |
|
61 |
65 |
resp = app.get('/manage/pricing/agenda/%s/' % agenda.pk)
|
62 |
66 |
assert AgendaPricing.objects.filter(agenda=agenda, pricing=pricing).count() == 2
|
63 |
67 |
assert resp.text.count('"/manage/pricing/%s/"' % pricing.pk) == 2
|
64 |
68 |
|
|
69 |
resp = app.get('/manage/pricing/agenda/%s/pricing/add/' % agenda.pk)
|
|
70 |
# starts on last date_end
|
|
71 |
assert resp.form['date_start'].value == '2022-09-01'
|
|
72 |
|
65 |
73 |
|
66 |
74 |
def test_edit_agenda_pricing(app, admin_user):
|
67 |
75 |
agenda = Agenda.objects.create(label='Foo Bar')
|
... | ... | |
90 |
98 |
app = login(app)
|
91 |
99 |
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
92 |
100 |
resp = resp.click(href='/manage/pricing/agenda/%s/pricing/%s/edit/' % (agenda.pk, agenda_pricing.pk))
|
|
101 |
assert resp.form['date_start'].value == '2021-09-01'
|
93 |
102 |
resp.form['pricing'] = pricing2.pk
|
94 |
103 |
resp.form['date_start'] = '2021-09-01'
|
95 |
104 |
resp.form['date_end'] = '2021-09-01'
|
96 |
|
-
|