From 6f093e0c1ad0504525624858d0d85758f040f43f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Fri, 20 May 2022 09:50:28 +0200
Subject: [PATCH 2/3] pricing: remove _as_manager tests (#65442)

---
 tests/pricing/test_manager.py | 273 ----------------------------------
 1 file changed, 273 deletions(-)

diff --git a/tests/pricing/test_manager.py b/tests/pricing/test_manager.py
index 40d80f7..f5dae39 100644
--- a/tests/pricing/test_manager.py
+++ b/tests/pricing/test_manager.py
@@ -12,14 +12,6 @@ from tests.utils import login
 pytestmark = pytest.mark.django_db
 
 
-@pytest.fixture
-def agenda_with_restrictions(manager_user):
-    agenda = Agenda(label='Foo Bar')
-    agenda.view_role = manager_user.groups.all()[0]
-    agenda.save()
-    return agenda
-
-
 def test_export_site(settings, freezer, app, admin_user):
     freezer.move_to('2020-06-15')
     login(app)
@@ -56,15 +48,6 @@ def test_export_site(settings, freezer, app, admin_user):
     assert 'pricing_models' not in site_json
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_list_pricings_as_manager(app, manager_user, agenda_with_restrictions):
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/', status=403)
-
-    resp = app.get('/manage/')
-    assert 'Pricing' not in resp.text
-
-
 def test_add_pricing(settings, app, admin_user):
     app = login(app)
     resp = app.get('/manage/')
@@ -78,12 +61,6 @@ def test_add_pricing(settings, app, admin_user):
     assert pricing.slug == 'pricing-model-for-lunch'
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_add_pricing_as_manager(app, manager_user):
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/add/', status=403)
-
-
 def test_detail_pricing(app, admin_user):
     pricing = Pricing.objects.create(label='Model')
 
@@ -94,14 +71,6 @@ def test_detail_pricing(app, admin_user):
     assert '/manage/pricing/%s/delete/' % pricing.pk in resp
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_detail_pricing_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/' % pricing.pk, status=403)
-
-
 def test_edit_pricing(app, admin_user):
     pricing = Pricing.objects.create(label='Model 1')
     pricing2 = Pricing.objects.create(label='Model 2')
@@ -122,14 +91,6 @@ def test_edit_pricing(app, admin_user):
     assert pricing.slug == 'foo-bar'
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_edit_pricing_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/edit/' % pricing.pk, status=403)
-
-
 def test_delete_pricing(app, admin_user):
     pricing = Pricing.objects.create(label='Model')
 
@@ -141,14 +102,6 @@ def test_delete_pricing(app, admin_user):
     assert Pricing.objects.exists() is False
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_delete_pricing_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/delete/' % pricing.pk, status=403)
-
-
 def test_duplicate_pricing(app, admin_user):
     pricing = Pricing.objects.create(label='Model')
     assert Pricing.objects.count() == 1
@@ -172,14 +125,6 @@ def test_duplicate_pricing(app, admin_user):
     assert 'hop' in resp.text
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_duplicate_pricing_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/duplicate/' % pricing.pk, status=403)
-
-
 @pytest.mark.freeze_time('2021-07-08')
 def test_import_pricing(app, admin_user):
     pricing = Pricing.objects.create(label='Model')
@@ -291,14 +236,6 @@ def test_pricing_edit_extra_variables(app, admin_user):
     assert '<i>foo</i>' in resp
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_pricing_edit_extra_variables_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/variable/' % pricing.pk, status=403)
-
-
 def test_pricing_add_category(app, admin_user):
     pricing = Pricing.objects.create(label='Model')
     category1 = CriteriaCategory.objects.create(label='Cat 1')
@@ -356,14 +293,6 @@ def test_pricing_add_category(app, admin_user):
     app.get('/manage/pricing/%s/category/add/' % pricing.pk, status=404)
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_pricing_add_category_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/category/add/' % pricing.pk, status=403)
-
-
 def test_pricing_edit_category(app, admin_user):
     category1 = CriteriaCategory.objects.create(label='Cat 1')
     criteria1 = Criteria.objects.create(label='Crit 1', category=category1)
@@ -406,16 +335,6 @@ def test_pricing_edit_category(app, admin_user):
     assert list(pricing.criterias.order_by('pk')) == [criteria1, criteria4, criteria5]
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_pricing_edit_category_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-    category = CriteriaCategory.objects.create(label='Cat')
-    pricing.categories.add(category, through_defaults={'order': 1})
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/category/%s/edit/' % (pricing.pk, category.pk), status=403)
-
-
 def test_pricing_delete_category(app, admin_user):
     category1 = CriteriaCategory.objects.create(label='Cat 1')
     criteria1 = Criteria.objects.create(label='Crit 1', category=category1)
@@ -441,15 +360,6 @@ def test_pricing_delete_category(app, admin_user):
     app.get('/manage/pricing/%s/category/%s/delete/' % (pricing.pk, 0), status=404)
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_pricing_delete_category_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-    category = CriteriaCategory.objects.create(label='Cat')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/category/%s/delete/' % (pricing.pk, category.pk), status=403)
-
-
 def test_pricing_reorder_categories(app, admin_user):
     category1 = CriteriaCategory.objects.create(label='Cat 1')
     category2 = CriteriaCategory.objects.create(label='Cat 2')
@@ -515,20 +425,6 @@ def test_pricing_reorder_categories(app, admin_user):
     ]
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_pricing_reorder_categories_as_manager(app, manager_user):
-    pricing = Pricing.objects.create(label='Model')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/%s/order/' % (pricing.pk), status=403)
-
-
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_list_criterias_as_manager(app, manager_user):
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criterias/', status=403)
-
-
 def test_add_category(settings, app, admin_user):
     app = login(app)
     resp = app.get('/manage/')
@@ -543,12 +439,6 @@ def test_add_category(settings, app, admin_user):
     assert category.slug == 'qf'
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_add_category_as_manager(app, manager_user):
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criteria/category/add/', status=403)
-
-
 def test_edit_category(app, admin_user):
     category = CriteriaCategory.objects.create(label='QF')
     category2 = CriteriaCategory.objects.create(label='Domicile')
@@ -569,14 +459,6 @@ def test_edit_category(app, admin_user):
     assert category.slug == 'baz2'
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_edit_category_as_manager(app, manager_user):
-    category = CriteriaCategory.objects.create(label='Foo bar')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criteria/category/%s/edit/' % category.pk, status=403)
-
-
 def test_delete_category(app, admin_user):
     category = CriteriaCategory.objects.create(label='QF')
     Criteria.objects.create(label='QF 1', category=category)
@@ -590,14 +472,6 @@ def test_delete_category(app, admin_user):
     assert Criteria.objects.exists() is False
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_delete_category_as_manager(app, manager_user):
-    category = CriteriaCategory.objects.create(label='Foo bar')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criteria/category/%s/delete/' % category.pk, status=403)
-
-
 def test_add_criteria(app, admin_user):
     category = CriteriaCategory.objects.create(label='QF')
 
@@ -632,14 +506,6 @@ def test_add_criteria(app, admin_user):
     assert criteria.order == 2
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_add_criteria_as_manager(app, manager_user):
-    category = CriteriaCategory.objects.create(label='Foo bar')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criteria/category/%s/add/' % category.pk, status=403)
-
-
 def test_edit_criteria(app, admin_user):
     category = CriteriaCategory.objects.create(label='QF')
     criteria = Criteria.objects.create(label='QF 1', category=category)
@@ -667,15 +533,6 @@ def test_edit_criteria(app, admin_user):
     assert criteria.condition == 'qf <= 1'
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_edit_criteria_as_manager(app, manager_user):
-    category = CriteriaCategory.objects.create(label='QF')
-    criteria = Criteria.objects.create(label='QF 1', category=category)
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criteria/category/%s/%s/edit/' % (category.pk, criteria.pk), status=403)
-
-
 def test_delete_criteria(app, admin_user):
     category = CriteriaCategory.objects.create(label='QF')
     criteria = Criteria.objects.create(label='QF 1', category=category)
@@ -689,15 +546,6 @@ def test_delete_criteria(app, admin_user):
     assert Criteria.objects.exists() is False
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_delete_criteria_as_manager(app, manager_user):
-    category = CriteriaCategory.objects.create(label='QF')
-    criteria = Criteria.objects.create(label='QF 1', category=category)
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criteria/category/%s/%s/delete/' % (category.pk, criteria.pk), status=403)
-
-
 def test_reorder_criterias(app, admin_user):
     category = CriteriaCategory.objects.create(label='QF')
     criteria1 = Criteria.objects.create(label='QF 1', category=category)
@@ -757,14 +605,6 @@ def test_reorder_criterias(app, admin_user):
     assert list(category.criterias.values_list('order', flat=True).order_by('order')) == [1, 2, 3, 4]
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_reorder_criterias_as_manager(app, manager_user):
-    category = CriteriaCategory.objects.create(label='QF')
-
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/criteria/category/%s/order/' % (category.pk), status=403)
-
-
 @pytest.mark.freeze_time('2021-07-08')
 def test_import_criteria_category(app, admin_user):
     category = CriteriaCategory.objects.create(label='Foo bar')
@@ -883,12 +723,6 @@ def test_add_agenda_pricing(settings, app, admin_user):
     assert agenda_pricing.date_end == datetime.date(2023, 9, 1)
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_add_agenda_pricing_as_manager(app, manager_user, agenda_with_restrictions):
-    app = login(app, username='manager', password='manager')
-    app.get('/manage/pricing/agenda/%s/pricing/add/' % agenda_with_restrictions.pk, status=403)
-
-
 def test_edit_agenda_pricing(app, admin_user):
     agenda = Agenda.objects.create(label='Foo Bar')
     pricing = Pricing.objects.create(label='Model')
@@ -940,50 +774,6 @@ def test_edit_agenda_pricing(app, admin_user):
     app.get('/manage/pricing/agenda/%s/pricing/%s/edit/' % (agenda.pk, 0), status=404)
 
 
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_edit_agenda_pricing_as_manager(app, manager_user, agenda_with_restrictions):
-    pricing = Pricing.objects.create(label='Model')
-    agenda_pricing = AgendaPricing.objects.create(
-        agenda=agenda_with_restrictions,
-        pricing=pricing,
-        date_start=datetime.date(year=2021, month=9, day=1),
-        date_end=datetime.date(year=2021, month=10, day=1),
-    )
-    app = login(app, username='manager', password='manager')
-    app.get(
-        '/manage/pricing/agenda/%s/pricing/%s/edit/' % (agenda_with_restrictions.pk, agenda_pricing.pk),
-        status=403,
-    )
-
-    resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda_with_restrictions.pk, agenda_pricing.pk))
-    assert (
-        '/manage/pricing/agenda/%s/pricing/%s/edit/' % (agenda_with_restrictions.pk, agenda_pricing.pk)
-        not in resp
-    )
-
-
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_delete_agenda_pricing_as_manager(app, manager_user, agenda_with_restrictions):
-    pricing = Pricing.objects.create(label='Model')
-    agenda_pricing = AgendaPricing.objects.create(
-        agenda=agenda_with_restrictions,
-        pricing=pricing,
-        date_start=datetime.date(year=2021, month=9, day=1),
-        date_end=datetime.date(year=2021, month=10, day=1),
-    )
-    app = login(app, username='manager', password='manager')
-    app.get(
-        '/manage/pricing/agenda/%s/pricing/%s/delete/' % (agenda_with_restrictions.pk, agenda_pricing.pk),
-        status=403,
-    )
-
-    resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda_with_restrictions.pk, agenda_pricing.pk))
-    assert (
-        '/manage/pricing/agenda/%s/pricing/%s/delete/' % (agenda_with_restrictions.pk, agenda_pricing.pk)
-        not in resp
-    )
-
-
 def test_delete_agenda_pricing(app, admin_user):
     agenda = Agenda.objects.create(label='Foo Bar')
     pricing = Pricing.objects.create(label='Model')
@@ -1600,66 +1390,3 @@ def test_edit_agenda_pricing_matrix_empty(app, admin_user):
 
     app = login(app)
     app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, agenda_pricing.pk), status=404)
-
-
-@pytest.mark.xfail(reason='/manage/ limited to admin')
-def test_edit_agenda_pricing_matrix_as_manager(app, manager_user, agenda_with_restrictions):
-    category1 = CriteriaCategory.objects.create(label='Cat 1')
-    Criteria.objects.create(label='Crit 1-1', slug='crit-1-1', category=category1, order=1)
-    Criteria.objects.create(label='Crit 1-2', slug='crit-1-2', category=category1, order=2)
-    category2 = CriteriaCategory.objects.create(label='Cat 2')
-    category3 = CriteriaCategory.objects.create(label='Cat 3')
-    pricing = Pricing.objects.create(label='Model')
-    agenda_pricing = AgendaPricing.objects.create(
-        agenda=agenda_with_restrictions,
-        pricing=pricing,
-        date_start=datetime.date(year=2021, month=9, day=1),
-        date_end=datetime.date(year=2021, month=10, day=1),
-    )
-    pricing.categories.add(category1, through_defaults={'order': 1})
-    pricing.criterias.set(Criteria.objects.all())
-
-    def check():
-        resp = app.get(
-            '/manage/pricing/agenda/%s/pricing/%s/' % (agenda_with_restrictions.pk, agenda_pricing.pk)
-        )
-        assert (
-            '/manage/pricing/agenda/%s/pricing/%s/matrix/edit/'
-            % (agenda_with_restrictions.pk, agenda_pricing.pk)
-            not in resp
-        )
-        for slug in ['crit-1-1', 'crit-1-2']:
-            assert (
-                '/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
-                % (agenda_with_restrictions.pk, agenda_pricing.pk, slug)
-                not in resp
-            )
-
-    app = login(app, username='manager', password='manager')
-    app.get(
-        '/manage/pricing/agenda/%s/pricing/%s/matrix/edit/'
-        % (agenda_with_restrictions.pk, agenda_pricing.pk),
-        status=403,
-    )
-    check()
-
-    pricing.categories.add(category2, through_defaults={'order': 2})
-    app.get(
-        '/manage/pricing/agenda/%s/pricing/%s/matrix/edit/'
-        % (agenda_with_restrictions.pk, agenda_pricing.pk),
-        status=403,
-    )
-    check()
-
-    pricing.categories.add(category3, through_defaults={'order': 3})
-    app.get(
-        '/manage/pricing/agenda/%s/pricing/%s/matrix/crit-1-1/edit/'
-        % (agenda_with_restrictions.pk, agenda_pricing.pk),
-        status=403,
-    )
-    app.get(
-        '/manage/pricing/agenda/%s/pricing/%s/matrix/crit-1-2/edit/'
-        % (agenda_with_restrictions.pk, agenda_pricing.pk),
-        status=403,
-    )
-    check()
-- 
2.35.1

