summaryrefslogtreecommitdiffstats
path: root/tests/test_lingo_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_lingo_manager.py')
-rw-r--r--tests/test_lingo_manager.py57
1 files changed, 55 insertions, 2 deletions
diff --git a/tests/test_lingo_manager.py b/tests/test_lingo_manager.py
index 44c1f17..b226803 100644
--- a/tests/test_lingo_manager.py
+++ b/tests/test_lingo_manager.py
@@ -47,7 +47,6 @@ def test_add_regie(app, admin_user, payment_backend):
resp.forms[0]['slug'] = 'test'
resp.forms[0]['description'] = 'description'
resp.forms[0]['payment_backend'] = payment_backend.pk
- assert resp.form['is_default'].checked is True
resp = resp.forms[0].submit()
assert resp.location.endswith('/manage/lingo/regies/')
assert Regie.objects.count() == 1
@@ -68,6 +67,61 @@ def test_edit_regie(app, admin_user, payment_backend):
regie = Regie.objects.all()[0]
assert regie.description == 'other description'
+
+def test_edit_regie_dynamic_backend_fields(app, admin_user):
+ payment_backend = PaymentBackend.objects.create(
+ label='test1', slug='test1', service='systempayv2', service_options={'siret': '1234'})
+ regie = Regie.objects.create(
+ label='test-regie', slug='test-regie', payment_backend=payment_backend)
+ assert regie.transaction_options == {}
+
+ app = login(app)
+ resp = app.get('/manage/lingo/regies/%s/edit' % regie.pk, status=200)
+ resp.forms[0]['label'] = 'test-regie'
+ resp.forms[0]['slug'] = 'test-regie'
+ resp.forms[0]['description'] = 'description'
+ resp.forms[0]['payment_backend'] = payment_backend.pk
+
+ assert resp.forms[0]['manual_validation'].checked is False
+ resp.forms[0]['manual_validation'] = True
+ resp = resp.forms[0].submit()
+
+ assert Regie.objects.count() == 1
+
+ regie = Regie.objects.get(slug='test-regie')
+ assert regie.transaction_options['manual_validation']
+
+ # No dynamic fields if no backend capabilities
+ payment_backend_dummy = PaymentBackend.objects.create(
+ label='test1', slug='test-dummy', service='dummy', service_options={'siret': '1234'})
+ regie_dummy = Regie.objects.create(
+ label='test-regie-2', slug='test-regie-2', payment_backend=payment_backend_dummy)
+
+ resp = app.get('/manage/lingo/regies/%s/edit' % regie_dummy.pk, status=200)
+ assert 'manual_validation' not in resp.forms[0].fields
+ resp.forms[0]['label'] = 'Test'
+ resp.forms[0]['slug'] = 'test-regie-2'
+ resp.forms[0]['description'] = 'description'
+ resp.forms[0]['payment_backend'] = payment_backend_dummy.pk
+ resp = resp.forms[0].submit()
+
+ regie_dummy = Regie.objects.get(slug='test-regie-2')
+ assert regie_dummy.transaction_options == {}
+
+ # Change backend
+ resp = app.get('/manage/lingo/regies/%s/edit' % regie.pk, status=200)
+ resp.forms[0]['label'] = 'test-regie'
+ resp.forms[0]['slug'] = 'test-regie'
+ resp.forms[0]['description'] = 'description'
+ resp.forms[0]['payment_backend'] = payment_backend_dummy.pk
+
+ assert resp.forms[0]['manual_validation'].checked is True
+ resp.forms[0]['manual_validation'] = True
+ resp = resp.forms[0].submit()
+
+ regie = Regie.objects.get(slug='test-regie')
+ assert regie.transaction_options == {}
+
def test_delete_regie(app, admin_user, payment_backend):
test_add_regie(app, admin_user, payment_backend)
app = login(app)
@@ -88,7 +142,6 @@ def test_add_second_regie(app, admin_user, payment_backend):
resp.forms[0]['slug'] = 'test2'
resp.forms[0]['description'] = 'description'
resp.forms[0]['payment_backend'] = payment_backend.pk
- assert resp.form['is_default'].checked is False
resp = resp.forms[0].submit()
assert resp.location.endswith('/manage/lingo/regies/')