1009 |
1009 |
assert cell.get_additional_label() == 'test'
|
1010 |
1010 |
|
1011 |
1011 |
|
|
1012 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
|
1013 |
def test_manager_care_forms_cell(mock_send, app, admin_user):
|
|
1014 |
page = Page(title='One', slug='one', template_name='standard')
|
|
1015 |
page.save()
|
|
1016 |
app = login(app)
|
|
1017 |
resp = app.get('/manage/pages/%s/' % page.id)
|
|
1018 |
resp = app.get(
|
|
1019 |
resp.html.find('option', **{'data-add-url': re.compile('wcscareformscell')})['data-add-url']
|
|
1020 |
)
|
|
1021 |
|
|
1022 |
cells = Page.objects.get(id=page.id).get_cells()
|
|
1023 |
assert len(cells) == 1
|
|
1024 |
assert isinstance(cells[0], WcsCareFormsCell)
|
|
1025 |
|
|
1026 |
resp = app.get('/manage/pages/%s/' % page.id)
|
|
1027 |
assert not resp.pyquery('[data-tab-slug="general"] input[name$="custom_title"]')
|
|
1028 |
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="custom_title"]')
|
|
1029 |
assert (
|
|
1030 |
resp.pyquery.find('div.cell [data-tab-slug="advanced"] input[name$="cache_duration"]').val() == '120'
|
|
1031 |
)
|
|
1032 |
resp.forms[0]['c%s-cache_duration' % cells[0].get_reference()] = '10'
|
|
1033 |
manager_submit_cell(resp.forms[0])
|
|
1034 |
cells[0].refresh_from_db()
|
|
1035 |
assert cells[0].cache_duration == 10
|
|
1036 |
|
|
1037 |
|
1012 |
1038 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
1013 |
1039 |
def test_care_forms_cell_render(mock_send, context):
|
1014 |
1040 |
page = Page(title='xxx', slug='test_care_forms_cell_render', template_name='standard')
|
... | ... | |
1029 |
1055 |
is_portal_agent.return_value = True
|
1030 |
1056 |
result = cell.render(context)
|
1031 |
1057 |
|
|
1058 |
assert 'Forms to process - test' in result
|
1032 |
1059 |
assert 'http://127.0.0.1:8999/backoffice/management/foobar/1' in result
|
1033 |
1060 |
assert 'http://127.0.0.1:8999/backoffice/management/foobar/2' in result
|
1034 |
1061 |
assert '"http://127.0.0.1:8999/backoffice/management/listing"' in result
|
|
1062 |
assert 'Forms to process - test2' in result
|
1035 |
1063 |
assert 'http://127.0.0.2:8999/backoffice/management/foobar/1' in result
|
1036 |
1064 |
assert 'http://127.0.0.2:8999/backoffice/management/foobar/2' in result
|
1037 |
1065 |
assert '"http://127.0.0.2:8999/backoffice/management/listing"' in result
|
1038 |
1066 |
|
|
1067 |
cell.custom_title = 'Foo Bar'
|
1039 |
1068 |
with mock.patch('combo.apps.wcs.models.is_portal_agent') as is_portal_agent:
|
1040 |
1069 |
is_portal_agent.return_value = False
|
1041 |
1070 |
result = cell.render(context)
|
1042 |
1071 |
|
|
1072 |
assert 'Forms to process - test' not in result
|
|
1073 |
assert 'Foo Bar' in result
|
1043 |
1074 |
assert 'http://127.0.0.1:8999/foobar/1' in result
|
1044 |
1075 |
assert 'http://127.0.0.1:8999/foobar/2' in result
|
|
1076 |
assert 'Forms to process - test2' not in result
|
|
1077 |
assert 'Foo Bar' in result
|
1045 |
1078 |
assert 'http://127.0.0.2:8999/foobar/1' in result
|
1046 |
1079 |
assert 'http://127.0.0.2:8999/foobar/2' in result
|
1047 |
1080 |
assert '/listing' not in result
|
... | ... | |
1621 |
1654 |
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="custom_title"]')
|
1622 |
1655 |
|
1623 |
1656 |
|
1624 |
|
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
1625 |
|
def test_manager_forms_in_your_care_cell(mock_send, app, admin_user):
|
1626 |
|
page = Page(title='One', slug='one', template_name='standard')
|
1627 |
|
page.save()
|
1628 |
|
app = login(app)
|
1629 |
|
resp = app.get('/manage/pages/%s/' % page.id)
|
1630 |
|
resp = app.get(
|
1631 |
|
resp.html.find('option', **{'data-add-url': re.compile('wcscareformscell')})['data-add-url']
|
1632 |
|
)
|
1633 |
|
|
1634 |
|
cells = Page.objects.get(id=page.id).get_cells()
|
1635 |
|
assert len(cells) == 1
|
1636 |
|
assert isinstance(cells[0], WcsCareFormsCell)
|
1637 |
|
|
1638 |
|
resp = app.get('/manage/pages/%s/' % page.id)
|
1639 |
|
assert (
|
1640 |
|
resp.pyquery.find('div.cell [data-tab-slug="advanced"] input[name$="cache_duration"]').val() == '120'
|
1641 |
|
)
|
1642 |
|
resp.forms[0]['c%s-cache_duration' % cells[0].get_reference()] = '10'
|
1643 |
|
manager_submit_cell(resp.forms[0])
|
1644 |
|
cells[0].refresh_from_db()
|
1645 |
|
assert cells[0].cache_duration == 10
|
1646 |
|
|
1647 |
|
|
1648 |
1657 |
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
1649 |
1658 |
def test_manager_cards_cell(mock_send, app, admin_user):
|
1650 |
1659 |
page = Page.objects.create(title='xxx', slug='test_cards_cell_save_cache', template_name='standard')
|
1651 |
|
-
|