130 |
130 |
def test_agendas_api(app):
|
131 |
131 |
category_a = Category.objects.create(label='Category A')
|
132 |
132 |
category_b = Category.objects.create(label='Category B')
|
133 |
|
event_agenda = Agenda.objects.create(label='Foo bar', category=category_a)
|
|
133 |
group = AbsenceReasonGroup.objects.create(label='Foo')
|
|
134 |
reason = AbsenceReason.objects.create(group=group, label='Foo bar')
|
|
135 |
reason2 = AbsenceReason.objects.create(group=group, label='Foo bar baz')
|
|
136 |
event_agenda = Agenda.objects.create(label='Foo bar', category=category_a, absence_reasons_group=group)
|
134 |
137 |
Agenda.objects.create(label='Foo bar 2', category=category_a)
|
|
138 |
Agenda.objects.create(label='Foo bar 3', absence_reasons_group=group)
|
135 |
139 |
meetings_agenda1 = Agenda.objects.create(label='Foo bar Meeting', kind='meetings', category=category_b)
|
136 |
140 |
Agenda.objects.create(label='Foo bar Meeting 2', kind='meetings')
|
137 |
141 |
resource1 = Resource.objects.create(label='Resource 1', description='Foo bar Resource 1')
|
... | ... | |
151 |
155 |
'kind': 'events',
|
152 |
156 |
'minimal_booking_delay': 1,
|
153 |
157 |
'maximal_booking_delay': 56,
|
|
158 |
'absence_reasons': [
|
|
159 |
{'slug': reason.slug, 'label': reason.label},
|
|
160 |
{'slug': reason2.slug, 'label': reason2.label},
|
|
161 |
],
|
154 |
162 |
'api': {
|
155 |
163 |
'datetimes_url': 'http://testserver/api/agenda/foo-bar/datetimes/',
|
156 |
164 |
'fillslots_url': 'http://testserver/api/agenda/foo-bar/fillslots/',
|
... | ... | |
168 |
176 |
'fillslots_url': 'http://testserver/api/agenda/foo-bar-2/fillslots/',
|
169 |
177 |
},
|
170 |
178 |
},
|
|
179 |
{
|
|
180 |
'text': 'Foo bar 3',
|
|
181 |
'id': 'foo-bar-3',
|
|
182 |
'kind': 'events',
|
|
183 |
'slug': 'foo-bar-3',
|
|
184 |
'minimal_booking_delay': 1,
|
|
185 |
'maximal_booking_delay': 56,
|
|
186 |
'absence_reasons': [
|
|
187 |
{'slug': reason.slug, 'label': reason.label},
|
|
188 |
{'slug': reason2.slug, 'label': reason2.label},
|
|
189 |
],
|
|
190 |
'api': {
|
|
191 |
'datetimes_url': 'http://testserver/api/agenda/foo-bar-3/datetimes/',
|
|
192 |
'fillslots_url': 'http://testserver/api/agenda/foo-bar-3/fillslots/',
|
|
193 |
},
|
|
194 |
},
|
171 |
195 |
{
|
172 |
196 |
'text': 'Foo bar Meeting',
|
173 |
197 |
'id': 'foo-bar-meeting',
|
... | ... | |
216 |
240 |
}
|
217 |
241 |
|
218 |
242 |
resp = app.get('/api/agenda/', params={'q': 'foo'})
|
219 |
|
assert len(resp.json['data']) == 4
|
|
243 |
assert len(resp.json['data']) == 5
|
220 |
244 |
resp = app.get('/api/agenda/', params={'q': 'MEET'})
|
221 |
245 |
assert len(resp.json['data']) == 2
|
222 |
246 |
resp = app.get('/api/agenda/', params={'q': ''})
|
... | ... | |
224 |
248 |
|
225 |
249 |
with CaptureQueriesContext(connection) as ctx:
|
226 |
250 |
resp = app.get('/api/agenda/')
|
227 |
|
assert len(ctx.captured_queries) == 3
|
|
251 |
assert len(ctx.captured_queries) == 4
|
228 |
252 |
with CaptureQueriesContext(connection) as ctx:
|
229 |
253 |
resp = app.get('/api/agenda/', params={'q': 'MEET'})
|
230 |
254 |
assert len(ctx.captured_queries) == 2
|
... | ... | |
233 |
257 |
assert len(resp.json['data']) == 0
|
234 |
258 |
|
235 |
259 |
resp = app.get('/api/agenda/', params={'category': ''})
|
236 |
|
assert len(resp.json['data']) == 5
|
|
260 |
assert len(resp.json['data']) == 6
|
237 |
261 |
resp = app.get('/api/agenda/', params={'category': '__none__'})
|
238 |
|
assert len(resp.json['data']) == 2
|
|
262 |
assert len(resp.json['data']) == 3
|
239 |
263 |
resp = app.get('/api/agenda/', params={'category': 'category-a'})
|
240 |
264 |
assert len(resp.json['data']) == 2
|
241 |
265 |
resp = app.get('/api/agenda/', params={'category': 'category-b'})
|
... | ... | |
309 |
333 |
|
310 |
334 |
with CaptureQueriesContext(connection) as ctx:
|
311 |
335 |
resp = app.get('/api/agenda/', params={'with_open_events': '1'})
|
312 |
|
assert len(ctx.captured_queries) == 4
|
|
336 |
assert len(ctx.captured_queries) == 5
|
313 |
337 |
|
314 |
338 |
|
315 |
339 |
def test_agendas_meetingtypes_api(app, some_data, meetings_agenda):
|
316 |
|
-
|