157 |
157 |
agenda.kind = 'meetings'
|
158 |
158 |
agenda.save()
|
159 |
159 |
app.post('/api/agenda/%s/check/%s/' % (agenda.slug, event.slug), status=404)
|
160 |
160 |
agenda.kind = 'virtual'
|
161 |
161 |
agenda.save()
|
162 |
162 |
app.post('/api/agenda/%s/check/%s/' % (agenda.slug, event.slug), status=404)
|
163 |
163 |
|
164 |
164 |
|
|
165 |
@pytest.mark.parametrize(
|
|
166 |
'days_in, days_out, err_msg',
|
|
167 |
[
|
|
168 |
(1, None, 'Expected a list of items but got type "int".'),
|
|
169 |
('2', [2], None),
|
|
170 |
([3], [3], None),
|
|
171 |
(['4'], [4], None),
|
|
172 |
([1, 2], [1, 2], None),
|
|
173 |
(['2', '3'], [2, 3], None),
|
|
174 |
('4, 5', [4, 5], None),
|
|
175 |
],
|
|
176 |
)
|
|
177 |
def test_string_or_list_serialiser(app, user, days_in, days_out, err_msg):
|
|
178 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
179 |
agenda = Agenda(label='Foo bar')
|
|
180 |
agenda.maximal_booking_delay = 0
|
|
181 |
agenda.save()
|
|
182 |
api_url = '/api/agenda/%s/event/' % (agenda.slug)
|
|
183 |
|
|
184 |
params = {
|
|
185 |
'start_datetime': '2022-02-03 16:00',
|
|
186 |
'places': '1',
|
|
187 |
'recurrence_days': days_in,
|
|
188 |
}
|
|
189 |
if not err_msg:
|
|
190 |
resp = app.post_json(api_url, params=params)
|
|
191 |
assert not resp.json['err']
|
|
192 |
assert Event.objects.get().recurrence_days == days_out
|
|
193 |
else:
|
|
194 |
resp = app.post_json(api_url, params=params, status=400)
|
|
195 |
assert resp.json['err_desc'] == 'invalid payload'
|
|
196 |
assert resp.json['errors']['recurrence_days'][0] == err_msg
|
|
197 |
|
|
198 |
|
165 |
199 |
@pytest.mark.freeze_time('2021-11-01')
|
166 |
200 |
def test_add_event(app, user):
|
167 |
201 |
api_url = '/api/agenda/%s/event/' % ('999')
|
168 |
202 |
|
169 |
203 |
# no authentication
|
170 |
204 |
resp = app.post(api_url, status=401)
|
171 |
205 |
assert resp.json['detail'] == 'Authentication credentials were not provided.'
|
172 |
206 |
|
173 |
|
-
|