2335 |
2335 |
# but only one cell on the page, no relations to follow
|
2336 |
2336 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2337 |
2337 |
('--', True, 'Identifier from page URL'),
|
|
2338 |
('__all__', False, 'All cards'),
|
|
2339 |
('', False, 'Other Card Identifiers'),
|
|
2340 |
]
|
|
2341 |
|
|
2342 |
# all cards
|
|
2343 |
cell.related_card_path = '__all__'
|
|
2344 |
cell.save()
|
|
2345 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
|
2346 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
|
2347 |
('--', False, 'Identifier from page URL'),
|
|
2348 |
('__all__', True, 'All cards'),
|
2338 |
2349 |
('', False, 'Other Card Identifiers'),
|
2339 |
2350 |
]
|
2340 |
2351 |
|
2341 |
2352 |
# add a second cell, related to the first card model
|
|
2353 |
cell.related_card_path = ''
|
|
2354 |
cell.save()
|
2342 |
2355 |
cell2 = WcsCardInfosCell.objects.create(
|
2343 |
2356 |
page=page, placeholder='content', order=1, carddef_reference='default:card_b'
|
2344 |
2357 |
)
|
... | ... | |
2346 |
2359 |
# still no relation to follow
|
2347 |
2360 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2348 |
2361 |
('--', True, 'Identifier from page URL'),
|
|
2362 |
('__all__', False, 'All cards'),
|
2349 |
2363 |
('', False, 'Other Card Identifiers'),
|
2350 |
2364 |
]
|
2351 |
2365 |
# no cell with id and slug
|
2352 |
2366 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2353 |
2367 |
('--', True, 'Identifier from page URL'),
|
|
2368 |
('__all__', False, 'All cards'),
|
2354 |
2369 |
('', False, 'Other Card Identifiers'),
|
2355 |
2370 |
]
|
2356 |
2371 |
|
... | ... | |
2361 |
2376 |
# still no relation to follow
|
2362 |
2377 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2363 |
2378 |
('--', True, 'Identifier from page URL'),
|
|
2379 |
('__all__', False, 'All cards'),
|
2364 |
2380 |
('', False, 'Other Card Identifiers'),
|
2365 |
2381 |
]
|
2366 |
2382 |
# multiple relations to follow
|
2367 |
2383 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2368 |
2384 |
('--', True, 'Identifier from page URL'),
|
|
2385 |
('__all__', False, 'All cards'),
|
2369 |
2386 |
('', False, 'Other Card Identifiers'),
|
2370 |
2387 |
('sluga/cardb', False, 'sluga/cardb'),
|
2371 |
2388 |
('sluga/cardsb', False, 'sluga/cardsb'),
|
... | ... | |
2382 |
2399 |
# still no relation to follow
|
2383 |
2400 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2384 |
2401 |
('--', False, 'Identifier from page URL'),
|
|
2402 |
('__all__', False, 'All cards'),
|
2385 |
2403 |
('', True, 'Other Card Identifiers'),
|
2386 |
2404 |
]
|
2387 |
2405 |
# can not user cell with multiple ids as reference
|
2388 |
2406 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2389 |
2407 |
('--', True, 'Identifier from page URL'),
|
|
2408 |
('__all__', False, 'All cards'),
|
2390 |
2409 |
('', False, 'Other Card Identifiers'),
|
2391 |
2410 |
]
|
2392 |
2411 |
|
... | ... | |
2399 |
2418 |
# multiple relations to follow
|
2400 |
2419 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2401 |
2420 |
('--', True, 'Identifier from page URL'),
|
|
2421 |
('__all__', False, 'All cards'),
|
2402 |
2422 |
('', False, 'Other Card Identifiers'),
|
2403 |
2423 |
('slugb/reverse:cardb', False, 'slugb/cardb (reverse)'),
|
2404 |
2424 |
('slugb/reverse:cardsb', False, 'slugb/cardsb (reverse)'),
|
... | ... | |
2407 |
2427 |
# still multiple relations to follow
|
2408 |
2428 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2409 |
2429 |
('--', True, 'Identifier from page URL'),
|
|
2430 |
('__all__', False, 'All cards'),
|
2410 |
2431 |
('', False, 'Other Card Identifiers'),
|
2411 |
2432 |
('sluga/cardb', False, 'sluga/cardb'),
|
2412 |
2433 |
('sluga/cardsb', False, 'sluga/cardsb'),
|
... | ... | |
2427 |
2448 |
# no more relation to follow
|
2428 |
2449 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2429 |
2450 |
('--', True, 'Identifier from page URL'),
|
|
2451 |
('__all__', False, 'All cards'),
|
2430 |
2452 |
('', False, 'Other Card Identifiers'),
|
2431 |
2453 |
]
|
2432 |
2454 |
# still multiple relations to follow
|
2433 |
2455 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2434 |
2456 |
('--', False, 'Identifier from page URL'),
|
|
2457 |
('__all__', False, 'All cards'),
|
2435 |
2458 |
('', False, 'Other Card Identifiers'),
|
2436 |
2459 |
('sluga/cardb', True, 'sluga/cardb'),
|
2437 |
2460 |
('sluga/cardsb', False, 'sluga/cardsb'),
|
... | ... | |
2456 |
2479 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
2457 |
2480 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2458 |
2481 |
('--', True, 'Identifier from page URL'),
|
|
2482 |
('__all__', False, 'All cards'),
|
2459 |
2483 |
('', False, 'Other Card Identifiers'),
|
2460 |
2484 |
('slugd/cardd-foo/carde-foo', False, 'slugd/cardd-foo/carde-foo'),
|
2461 |
2485 |
('slugd/carde-foo', False, 'slugd/carde-foo'),
|
2462 |
2486 |
]
|
2463 |
2487 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2464 |
2488 |
('--', True, 'Identifier from page URL'),
|
|
2489 |
('__all__', False, 'All cards'),
|
2465 |
2490 |
('', False, 'Other Card Identifiers'),
|
2466 |
2491 |
('sluge/cardd-bar', False, 'sluge/cardd-bar'),
|
2467 |
2492 |
('sluge/reverse:carde-foo', False, 'sluge/carde-foo (reverse)'),
|
... | ... | |
2477 |
2502 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
2478 |
2503 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2479 |
2504 |
('--', True, 'Identifier from page URL'),
|
|
2505 |
('__all__', False, 'All cards'),
|
2480 |
2506 |
('', False, 'Other Card Identifiers'),
|
2481 |
2507 |
('slugd-bis/cardd-foo', False, 'slugd-bis/cardd-foo'),
|
2482 |
2508 |
('slugd-bis/reverse:cardd-foo', False, 'slugd-bis/cardd-foo (reverse)'),
|
... | ... | |
2485 |
2511 |
]
|
2486 |
2512 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2487 |
2513 |
('--', True, 'Identifier from page URL'),
|
|
2514 |
('__all__', False, 'All cards'),
|
2488 |
2515 |
('', False, 'Other Card Identifiers'),
|
2489 |
2516 |
('slugd/cardd-foo', False, 'slugd/cardd-foo'),
|
2490 |
2517 |
('slugd/reverse:cardd-foo', False, 'slugd/cardd-foo (reverse)'),
|
... | ... | |
2502 |
2529 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
2503 |
2530 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2504 |
2531 |
('--', True, 'Identifier from page URL'),
|
|
2532 |
('__all__', False, 'All cards'),
|
2505 |
2533 |
('', False, 'Other Card Identifiers'),
|
2506 |
2534 |
('sluge-bis/cardd-bar/carde-foo', False, 'sluge-bis/cardd-bar/carde-foo'),
|
2507 |
2535 |
]
|
2508 |
2536 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2509 |
2537 |
('--', True, 'Identifier from page URL'),
|
|
2538 |
('__all__', False, 'All cards'),
|
2510 |
2539 |
('', False, 'Other Card Identifiers'),
|
2511 |
2540 |
('sluge/cardd-bar/carde-foo', False, 'sluge/cardd-bar/carde-foo'),
|
2512 |
2541 |
]
|
... | ... | |
3189 |
3218 |
)
|
3190 |
3219 |
|
3191 |
3220 |
|
|
3221 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
|
3222 |
def test_card_cell_render_all_cards(mock_send, nocache, app):
|
|
3223 |
page = Page.objects.create(title='xxx', slug='foo', template_name='standard')
|
|
3224 |
cell = WcsCardInfosCell.objects.create(
|
|
3225 |
page=page,
|
|
3226 |
placeholder='content',
|
|
3227 |
order=0,
|
|
3228 |
carddef_reference='default:card_model_1',
|
|
3229 |
related_card_path='__all__',
|
|
3230 |
)
|
|
3231 |
|
|
3232 |
cell_url = reverse(
|
|
3233 |
'combo-public-ajax-page-cell',
|
|
3234 |
kwargs={'page_pk': page.pk, 'cell_reference': cell.get_reference()},
|
|
3235 |
)
|
|
3236 |
|
|
3237 |
# check url called
|
|
3238 |
mock_send.reset_mock()
|
|
3239 |
resp = app.get(page.get_online_url())
|
|
3240 |
assert len(resp.context['cells']) == 3
|
|
3241 |
extra_ctx = re.findall(r'data-extra-context="(.*)"', resp.text)
|
|
3242 |
for i in range(0, 3):
|
|
3243 |
assert resp.context['cells'][i].pk == cell.pk
|
|
3244 |
assert resp.context['cells'][i].repeat_index == i
|
|
3245 |
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[i])
|
|
3246 |
assert cell_resp.context['repeat_index'] == i
|
|
3247 |
assert len(mock_send.call_args_list) == 7
|
|
3248 |
# page rendering
|
|
3249 |
assert '/api/cards/card_model_1/list' in mock_send.call_args_list[0][0][0].url
|
|
3250 |
# cell rendering
|
|
3251 |
for i in range(0, 3):
|
|
3252 |
assert '/api/cards/card_model_1/list' in mock_send.call_args_list[i * 2 + 1][0][0].url
|
|
3253 |
assert '/api/cards/card_model_1/list' in mock_send.call_args_list[i * 2 + 2][0][0].url
|
|
3254 |
assert 'filter-internal-id' not in mock_send.call_args_list[i * 2 + 2][0][0].url
|
|
3255 |
|
|
3256 |
|
3192 |
3257 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
3193 |
3258 |
def test_card_cell_render_identifier(mock_send, nocache, app):
|
3194 |
3259 |
page = Page.objects.create(
|
3195 |
|
-
|