|
|
|
@ -2184,7 +2184,7 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|
|
|
|
del context['card_model_1_id']
|
|
|
|
|
assert 'card_model_1_id' not in context
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2>Card Model 1</h2>' in result # default value
|
|
|
|
|
assert '>Card Model 1</h2>' in result # default value
|
|
|
|
|
assert '<p>Unknown Card</p>' in result
|
|
|
|
|
|
|
|
|
|
context['card_model_1_id'] = 11
|
|
|
|
@ -2197,12 +2197,12 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|
|
|
|
mock_resp.status_code = 500
|
|
|
|
|
requests_get.return_value = mock_resp
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2>Card Model 1</h2>' in result # default value
|
|
|
|
|
assert '>Card Model 1</h2>' in result # default value
|
|
|
|
|
assert '<p>Unknown Card</p>' in result
|
|
|
|
|
with mock.patch('combo.apps.wcs.models.requests.get') as requests_get:
|
|
|
|
|
requests_get.side_effect = ConnectionError()
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2>Card Model 1</h2>' in result # default value
|
|
|
|
|
assert '>Card Model 1</h2>' in result # default value
|
|
|
|
|
assert '<p>Unknown Card</p>' in result
|
|
|
|
|
|
|
|
|
|
context.pop('title')
|
|
|
|
@ -2210,7 +2210,7 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|
|
|
|
cell.save()
|
|
|
|
|
mock_send.reset_mock()
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2>Card Model 1 - aa</h2>' in result
|
|
|
|
|
assert '>Card Model 1 - aa</h2>' in result
|
|
|
|
|
assert '<div class="label">Page</div>' not in result
|
|
|
|
|
assert PyQuery(result).find('.label:contains("Field A") + .value').text() == '<i>a</i>'
|
|
|
|
|
assert PyQuery(result).find('.label:contains("Field B") + .value').text() == 'yes'
|
|
|
|
@ -2229,25 +2229,25 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|
|
|
|
cell.save()
|
|
|
|
|
assert cell.get_additional_label() == '<b>Foo bar {{ card.fields.fielda }}</b>'
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2><b>Foo bar <i>a</i></b></h2>' in result
|
|
|
|
|
assert '><b>Foo bar <i>a</i></b></h2>' in result
|
|
|
|
|
|
|
|
|
|
context.pop('title')
|
|
|
|
|
cell.custom_title = '{{ foobar }}'
|
|
|
|
|
cell.save()
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2>Card Model 1 - aa</h2>' in result # empty value from template, default value
|
|
|
|
|
assert '>Card Model 1 - aa</h2>' in result # empty value from template, default value
|
|
|
|
|
|
|
|
|
|
page.extra_variables = {'foobar': 'abcdef'}
|
|
|
|
|
page.save()
|
|
|
|
|
del page._cached_extra_variables # clear cache
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2>abcdef</h2>' in result
|
|
|
|
|
assert '>abcdef</h2>' in result
|
|
|
|
|
|
|
|
|
|
context.pop('title')
|
|
|
|
|
cell.custom_title = '{% if %}'
|
|
|
|
|
cell.save()
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert '<h2>Card Model 1 - aa</h2>' in result # template error, default value
|
|
|
|
|
assert '>Card Model 1 - aa</h2>' in result # template error, default value
|
|
|
|
|
|
|
|
|
|
context.pop('title')
|
|
|
|
|
cell.title_type = 'empty'
|
|
|
|
@ -2268,7 +2268,7 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|
|
|
|
kwargs={'page_pk': page.pk, 'cell_reference': cell.get_reference()},
|
|
|
|
|
)
|
|
|
|
|
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[0])
|
|
|
|
|
assert '<h2>Xhttp://testserverY</h2>' in cell_resp
|
|
|
|
|
assert '>Xhttp://testserverY</h2>' in cell_resp
|
|
|
|
|
|
|
|
|
|
cell.card_ids = '{{ cards|objects:"card_model_1"|getlist:"id"|join:"," }}'
|
|
|
|
|
cell.title_type = 'manual'
|
|
|
|
@ -2280,7 +2280,7 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|
|
|
|
extra_ctx = re.findall(r'data-extra-context="(.*)"', resp.text)
|
|
|
|
|
for i in range(0, 3):
|
|
|
|
|
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[i])
|
|
|
|
|
assert '<h2>Foo bar X%sY</h2>' % i in cell_resp
|
|
|
|
|
assert '>Foo bar X%sY</h2>' % i in cell_resp
|
|
|
|
|
|
|
|
|
|
cell.limit = 42
|
|
|
|
|
cell.save()
|
|
|
|
@ -2288,7 +2288,7 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|
|
|
|
extra_ctx = re.findall(r'data-extra-context="(.*)"', resp.text)
|
|
|
|
|
for i in range(0, 3):
|
|
|
|
|
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[i])
|
|
|
|
|
assert '<h2>Foo bar X%sY</h2>' % i in cell_resp
|
|
|
|
|
assert '>Foo bar X%sY</h2>' % i in cell_resp
|
|
|
|
|
assert 'data-paginate-by="42"' in resp
|
|
|
|
|
|
|
|
|
|
# using custom view
|
|
|
|
@ -2458,6 +2458,7 @@ def test_card_cell_card_mode_render_custom_schema_card_field(mock_send, context)
|
|
|
|
|
|
|
|
|
|
result = cell.render(context)
|
|
|
|
|
assert PyQuery(result).find('h3').text() == '<i>a</i>'
|
|
|
|
|
assert PyQuery(result).find('h2')[0].attrib['id'] == 'wcs-card-card_model_1-11'
|
|
|
|
|
|
|
|
|
|
cell.custom_schema['cells'][0] = {
|
|
|
|
|
'varname': 'fielda',
|
|
|
|
@ -2958,6 +2959,7 @@ def test_card_cell_card_mode_render_custom_schema_custom_entry(mock_send, contex
|
|
|
|
|
)
|
|
|
|
|
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[0])
|
|
|
|
|
assert '/api/wcs/file/' in PyQuery(cell_resp.text).find('.label').text()
|
|
|
|
|
assert PyQuery(cell_resp.text).find('h2')[0].attrib['id'] == 'wcs-card-card_model_1-11'
|
|
|
|
|
|
|
|
|
|
cell.custom_schema = {
|
|
|
|
|
'cells': [
|
|
|
|
@ -2992,6 +2994,7 @@ def test_card_cell_card_mode_render_custom_schema_custom_entry(mock_send, contex
|
|
|
|
|
for i in range(0, 3):
|
|
|
|
|
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[i])
|
|
|
|
|
assert PyQuery(cell_resp.text).find('.label').text() == 'Foo bar baz X%sY' % i
|
|
|
|
|
assert PyQuery(cell_resp.text).find('h2')[0].attrib['id'].startswith('wcs-card-card_model_1-')
|
|
|
|
|
|
|
|
|
|
# custom schema but empty
|
|
|
|
|
cell.custom_schema = {'cells': []}
|
|
|
|
|