From cd369db15a526f28dc3dc5d182d87224b00652ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Thu, 11 Aug 2022 14:09:37 +0200
Subject: [PATCH 4/8] tests: rename card cell tests with card display mode
 (#68063)

---
 tests/wcs/test_card.py | 87 ++++++++++++++++++++++++++----------------
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/tests/wcs/test_card.py b/tests/wcs/test_card.py
index 01d5846b..f05ce372 100644
--- a/tests/wcs/test_card.py
+++ b/tests/wcs/test_card.py
@@ -634,12 +634,16 @@ def test_card_cell_load(mock_send):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render(mock_send, context, app):
+def test_card_cell_card_mode_render(mock_send, context, app):
     page = Page.objects.create(title='xxx', template_name='standard')
-    cell = WcsCardInfosCell(page=page, placeholder='content', order=0)
-    cell.title_type = 'manual'
-    cell.custom_title = 'Foo bar {{ card.fields.title }}'
-    cell.save()
+    cell = WcsCardInfosCell.objects.create(
+        page=page,
+        placeholder='content',
+        order=0,
+        display_mode='card',
+        title_type='manual',
+        custom_title='Foo bar {{ card.fields.title }}',
+    )
 
     # carddef_reference is not defined
     context['card_model_1_id'] = 11
@@ -776,11 +780,15 @@ def test_card_cell_render(mock_send, context, app):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_text_field(mock_send, context):
+def test_card_cell_card_mode_render_text_field(mock_send, context):
     page = Page.objects.create(title='xxx', template_name='standard')
-    cell = WcsCardInfosCell(page=page, placeholder='content', order=0)
-    cell.carddef_reference = 'default:card_model_1'
-    cell.save()
+    cell = WcsCardInfosCell.objects.create(
+        page=page,
+        placeholder='content',
+        order=0,
+        display_mode='card',
+        carddef_reference='default:card_model_1',
+    )
 
     context['card_model_1_id'] = 11
     request = RequestFactory().get('/')
@@ -808,11 +816,15 @@ def test_card_cell_render_text_field(mock_send, context):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_email_field(mock_send, context):
+def test_card_cell_card_mode_render_email_field(mock_send, context):
     page = Page.objects.create(title='xxx', template_name='standard')
-    cell = WcsCardInfosCell(page=page, placeholder='content', order=0)
-    cell.carddef_reference = 'default:card_model_1'
-    cell.save()
+    cell = WcsCardInfosCell.objects.create(
+        page=page,
+        placeholder='content',
+        order=0,
+        display_mode='card',
+        carddef_reference='default:card_model_1',
+    )
 
     context['card_model_1_id'] = 11
     request = RequestFactory().get('/')
@@ -830,12 +842,16 @@ def test_card_cell_render_email_field(mock_send, context):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_string_with_url_field(mock_send, context):
+def test_card_cell_card_mode_render_string_with_url_field(mock_send, context):
     page = Page.objects.create(title='xxx', template_name='standard')
-    cell = WcsCardInfosCell(page=page, placeholder='content', order=0)
-    cell.carddef_reference = 'default:card_model_1'
-    cell.custom_title = 'Foo bar {{ card.fields.title }}'
-    cell.save()
+    cell = WcsCardInfosCell.objects.create(
+        page=page,
+        placeholder='content',
+        order=0,
+        display_mode='card',
+        carddef_reference='default:card_model_1',
+        custom_title='Foo bar {{ card.fields.title }}',
+    )
 
     context['card_model_1_id'] = 11
     request = RequestFactory().get('/')
@@ -854,7 +870,7 @@ def test_card_cell_render_string_with_url_field(mock_send, context):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_custom_schema_card_field(mock_send, context):
+def test_card_cell_card_mode_render_custom_schema_card_field(mock_send, context):
     page = Page.objects.create(title='xxx', template_name='standard')
     cell = WcsCardInfosCell.objects.create(
         page=page,
@@ -1004,7 +1020,7 @@ def test_card_cell_render_custom_schema_card_field(mock_send, context):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
+def test_card_cell_card_mode_render_custom_schema_card_empty_field(mock_send, context):
     page = Page.objects.create(title='xxx', template_name='standard')
     cell = WcsCardInfosCell.objects.create(
         page=page,
@@ -1105,7 +1121,7 @@ def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_custom_schema_custom_entry(mock_send, context, app):
+def test_card_cell_card_mode_render_custom_schema_custom_entry(mock_send, context, app):
     page = Page.objects.create(title='xxx', template_name='standard')
     cell = WcsCardInfosCell.objects.create(
         page=page,
@@ -1222,7 +1238,7 @@ def test_card_cell_render_custom_schema_custom_entry(mock_send, context, app):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_custom_schema_link_entry(mock_send, context, app):
+def test_card_cell_card_mode_render_custom_schema_link_entry(mock_send, context, app):
     page = Page.objects.create(title='xxx', template_name='standard')
     cell = WcsCardInfosCell.objects.create(
         page=page,
@@ -1280,7 +1296,7 @@ def test_card_cell_render_custom_schema_link_entry(mock_send, context, app):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_all_cards(mock_send, nocache, app):
+def test_card_cell_card_mode_render_all_cards(mock_send, nocache, app):
     page = Page.objects.create(title='xxx', slug='foo', template_name='standard')
     cell = WcsCardInfosCell.objects.create(
         page=page,
@@ -1316,7 +1332,7 @@ def test_card_cell_render_all_cards(mock_send, nocache, app):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_identifier(mock_send, nocache, app):
+def test_card_cell_card_mode_render_identifier(mock_send, nocache, app):
     page = Page.objects.create(
         title='xxx', slug='foo', template_name='standard', sub_slug='(?P<card_model_1_id>[a-z0-9]+)'
     )
@@ -1453,12 +1469,13 @@ def test_card_cell_render_identifier(mock_send, nocache, app):
 
 
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
-def test_card_cell_render_identifier_from_related(mock_send, nocache, app):
+def test_card_cell_card_mode_render_identifier_from_related(mock_send, nocache, app):
     page = Page.objects.create(title='xxx', slug='foo', template_name='standard')
     cell = WcsCardInfosCell.objects.create(
         page=page,
         placeholder='content',
         order=0,
+        display_mode='card',
         slug='sluga',
         carddef_reference='default:card_a',
         card_ids='1',
@@ -1993,10 +2010,13 @@ def test_card_cell_render_identifier_from_related(mock_send, nocache, app):
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
 def test_card_cell_only_for_user(mock_send, context, carddef_reference):
     page = Page.objects.create(title='xxx', template_name='standard')
-    cell = WcsCardInfosCell(page=page, placeholder='content', order=0)
-    cell.carddef_reference = carddef_reference
-    cell.only_for_user = False
-    cell.save()
+    cell = WcsCardInfosCell.objects.create(
+        page=page,
+        placeholder='content',
+        order=0,
+        carddef_reference=carddef_reference,
+        only_for_user=False,
+    )
 
     context['card_model_1_id'] = 11
     request = RequestFactory().get('/')
@@ -2037,9 +2057,12 @@ def test_card_cell_only_for_user(mock_send, context, carddef_reference):
 @mock.patch('requests.Session.send', side_effect=mocked_requests_send)
 def test_card_cell_render_user(mock_send, context, nocache, carddef_reference):
     page = Page.objects.create(title='xxx', template_name='standard')
-    cell = WcsCardInfosCell(page=page, placeholder='content', order=0)
-    cell.carddef_reference = carddef_reference
-    cell.save()
+    cell = WcsCardInfosCell.objects.create(
+        page=page,
+        placeholder='content',
+        order=0,
+        carddef_reference=carddef_reference,
+    )
 
     context['card_model_1_id'] = 11
     request = RequestFactory().get('/')
-- 
2.35.1

