2372 |
2372 |
# but only one cell on the page, no relations to follow
|
2373 |
2373 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2374 |
2374 |
('--', True, 'Identifier from page URL'),
|
|
2375 |
('__all__', False, 'All cards'),
|
|
2376 |
('', False, 'Other Card Identifiers'),
|
|
2377 |
]
|
|
2378 |
|
|
2379 |
# all cards
|
|
2380 |
cell.related_card_path = '__all__'
|
|
2381 |
cell.save()
|
|
2382 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
|
2383 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
|
2384 |
('--', False, 'Identifier from page URL'),
|
|
2385 |
('__all__', True, 'All cards'),
|
2375 |
2386 |
('', False, 'Other Card Identifiers'),
|
2376 |
2387 |
]
|
2377 |
2388 |
|
2378 |
2389 |
# add a second cell, related to the first card model
|
|
2390 |
cell.related_card_path = ''
|
|
2391 |
cell.save()
|
2379 |
2392 |
cell2 = WcsCardInfosCell.objects.create(
|
2380 |
2393 |
page=page, placeholder='content', order=1, carddef_reference='default:card_b'
|
2381 |
2394 |
)
|
... | ... | |
2383 |
2396 |
# still no relation to follow
|
2384 |
2397 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2385 |
2398 |
('--', True, 'Identifier from page URL'),
|
|
2399 |
('__all__', False, 'All cards'),
|
2386 |
2400 |
('', False, 'Other Card Identifiers'),
|
2387 |
2401 |
]
|
2388 |
2402 |
# no cell with id and slug
|
2389 |
2403 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2390 |
2404 |
('--', True, 'Identifier from page URL'),
|
|
2405 |
('__all__', False, 'All cards'),
|
2391 |
2406 |
('', False, 'Other Card Identifiers'),
|
2392 |
2407 |
]
|
2393 |
2408 |
|
... | ... | |
2398 |
2413 |
# still no relation to follow
|
2399 |
2414 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2400 |
2415 |
('--', True, 'Identifier from page URL'),
|
|
2416 |
('__all__', False, 'All cards'),
|
2401 |
2417 |
('', False, 'Other Card Identifiers'),
|
2402 |
2418 |
]
|
2403 |
2419 |
# multiple relations to follow
|
2404 |
2420 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2405 |
2421 |
('--', True, 'Identifier from page URL'),
|
|
2422 |
('__all__', False, 'All cards'),
|
2406 |
2423 |
('', False, 'Other Card Identifiers'),
|
2407 |
2424 |
('sluga/cardb', False, 'sluga/cardb'),
|
2408 |
2425 |
('sluga/cardsb', False, 'sluga/cardsb'),
|
... | ... | |
2419 |
2436 |
# still no relation to follow
|
2420 |
2437 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2421 |
2438 |
('--', False, 'Identifier from page URL'),
|
|
2439 |
('__all__', False, 'All cards'),
|
2422 |
2440 |
('', True, 'Other Card Identifiers'),
|
2423 |
2441 |
]
|
2424 |
2442 |
# can not user cell with multiple ids as reference
|
2425 |
2443 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2426 |
2444 |
('--', True, 'Identifier from page URL'),
|
|
2445 |
('__all__', False, 'All cards'),
|
2427 |
2446 |
('', False, 'Other Card Identifiers'),
|
2428 |
2447 |
]
|
2429 |
2448 |
|
... | ... | |
2436 |
2455 |
# multiple relations to follow
|
2437 |
2456 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2438 |
2457 |
('--', True, 'Identifier from page URL'),
|
|
2458 |
('__all__', False, 'All cards'),
|
2439 |
2459 |
('', False, 'Other Card Identifiers'),
|
2440 |
2460 |
('slugb/reverse:cardb', False, 'slugb/cardb (reverse)'),
|
2441 |
2461 |
('slugb/reverse:cardsb', False, 'slugb/cardsb (reverse)'),
|
... | ... | |
2444 |
2464 |
# still multiple relations to follow
|
2445 |
2465 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2446 |
2466 |
('--', True, 'Identifier from page URL'),
|
|
2467 |
('__all__', False, 'All cards'),
|
2447 |
2468 |
('', False, 'Other Card Identifiers'),
|
2448 |
2469 |
('sluga/cardb', False, 'sluga/cardb'),
|
2449 |
2470 |
('sluga/cardsb', False, 'sluga/cardsb'),
|
... | ... | |
2464 |
2485 |
# no more relation to follow
|
2465 |
2486 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2466 |
2487 |
('--', True, 'Identifier from page URL'),
|
|
2488 |
('__all__', False, 'All cards'),
|
2467 |
2489 |
('', False, 'Other Card Identifiers'),
|
2468 |
2490 |
]
|
2469 |
2491 |
# still multiple relations to follow
|
2470 |
2492 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2471 |
2493 |
('--', False, 'Identifier from page URL'),
|
|
2494 |
('__all__', False, 'All cards'),
|
2472 |
2495 |
('', False, 'Other Card Identifiers'),
|
2473 |
2496 |
('sluga/cardb', True, 'sluga/cardb'),
|
2474 |
2497 |
('sluga/cardsb', False, 'sluga/cardsb'),
|
... | ... | |
2493 |
2516 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
2494 |
2517 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2495 |
2518 |
('--', True, 'Identifier from page URL'),
|
|
2519 |
('__all__', False, 'All cards'),
|
2496 |
2520 |
('', False, 'Other Card Identifiers'),
|
2497 |
2521 |
('slugd/cardd-foo/carde-foo', False, 'slugd/cardd-foo/carde-foo'),
|
2498 |
2522 |
('slugd/carde-foo', False, 'slugd/carde-foo'),
|
2499 |
2523 |
]
|
2500 |
2524 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2501 |
2525 |
('--', True, 'Identifier from page URL'),
|
|
2526 |
('__all__', False, 'All cards'),
|
2502 |
2527 |
('', False, 'Other Card Identifiers'),
|
2503 |
2528 |
('sluge/cardd-bar', False, 'sluge/cardd-bar'),
|
2504 |
2529 |
('sluge/reverse:carde-foo', False, 'sluge/carde-foo (reverse)'),
|
... | ... | |
2514 |
2539 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
2515 |
2540 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2516 |
2541 |
('--', True, 'Identifier from page URL'),
|
|
2542 |
('__all__', False, 'All cards'),
|
2517 |
2543 |
('', False, 'Other Card Identifiers'),
|
2518 |
2544 |
('slugd-bis/cardd-foo', False, 'slugd-bis/cardd-foo'),
|
2519 |
2545 |
('slugd-bis/reverse:cardd-foo', False, 'slugd-bis/cardd-foo (reverse)'),
|
... | ... | |
2522 |
2548 |
]
|
2523 |
2549 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2524 |
2550 |
('--', True, 'Identifier from page URL'),
|
|
2551 |
('__all__', False, 'All cards'),
|
2525 |
2552 |
('', False, 'Other Card Identifiers'),
|
2526 |
2553 |
('slugd/cardd-foo', False, 'slugd/cardd-foo'),
|
2527 |
2554 |
('slugd/reverse:cardd-foo', False, 'slugd/cardd-foo (reverse)'),
|
... | ... | |
2539 |
2566 |
resp = app.get('/manage/pages/%s/' % page.pk)
|
2540 |
2567 |
assert resp.forms[0]['c%s-related_card_path' % cell.get_reference()].options == [
|
2541 |
2568 |
('--', True, 'Identifier from page URL'),
|
|
2569 |
('__all__', False, 'All cards'),
|
2542 |
2570 |
('', False, 'Other Card Identifiers'),
|
2543 |
2571 |
('sluge-bis/cardd-bar/carde-foo', False, 'sluge-bis/cardd-bar/carde-foo'),
|
2544 |
2572 |
]
|
2545 |
2573 |
assert resp.forms[1]['c%s-related_card_path' % cell2.get_reference()].options == [
|
2546 |
2574 |
('--', True, 'Identifier from page URL'),
|
|
2575 |
('__all__', False, 'All cards'),
|
2547 |
2576 |
('', False, 'Other Card Identifiers'),
|
2548 |
2577 |
('sluge/cardd-bar/carde-foo', False, 'sluge/cardd-bar/carde-foo'),
|
2549 |
2578 |
]
|
... | ... | |
3226 |
3255 |
)
|
3227 |
3256 |
|
3228 |
3257 |
|
|
3258 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
|
3259 |
def test_card_cell_render_all_cards(mock_send, nocache, app):
|
|
3260 |
page = Page.objects.create(title='xxx', slug='foo', template_name='standard')
|
|
3261 |
cell = WcsCardInfosCell.objects.create(
|
|
3262 |
page=page,
|
|
3263 |
placeholder='content',
|
|
3264 |
order=0,
|
|
3265 |
carddef_reference='default:card_model_1',
|
|
3266 |
related_card_path='__all__',
|
|
3267 |
)
|
|
3268 |
|
|
3269 |
cell_url = reverse(
|
|
3270 |
'combo-public-ajax-page-cell',
|
|
3271 |
kwargs={'page_pk': page.pk, 'cell_reference': cell.get_reference()},
|
|
3272 |
)
|
|
3273 |
|
|
3274 |
# check url called
|
|
3275 |
mock_send.reset_mock()
|
|
3276 |
resp = app.get(page.get_online_url())
|
|
3277 |
assert len(resp.context['cells']) == 3
|
|
3278 |
extra_ctx = re.findall(r'data-extra-context="(.*)"', resp.text)
|
|
3279 |
for i in range(0, 3):
|
|
3280 |
assert resp.context['cells'][i].pk == cell.pk
|
|
3281 |
assert resp.context['cells'][i].repeat_index == i
|
|
3282 |
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[i])
|
|
3283 |
assert cell_resp.context['repeat_index'] == i
|
|
3284 |
assert len(mock_send.call_args_list) == 7
|
|
3285 |
# page rendering
|
|
3286 |
assert '/api/cards/card_model_1/list' in mock_send.call_args_list[0][0][0].url
|
|
3287 |
# cell rendering
|
|
3288 |
for i in range(0, 3):
|
|
3289 |
assert '/api/cards/card_model_1/list' in mock_send.call_args_list[i * 2 + 1][0][0].url
|
|
3290 |
assert '/api/cards/card_model_1/list' in mock_send.call_args_list[i * 2 + 2][0][0].url
|
|
3291 |
assert 'filter-internal-id' not in mock_send.call_args_list[i * 2 + 2][0][0].url
|
|
3292 |
|
|
3293 |
|
3229 |
3294 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
3230 |
3295 |
def test_card_cell_render_identifier(mock_send, nocache, app):
|
3231 |
3296 |
page = Page.objects.create(
|
3232 |
|
-
|