392 |
392 |
location = urlparse.urlparse(resp.location)
|
393 |
393 |
assert location.path == '/'
|
394 |
394 |
assert location.hostname == 'dummy-payment.demo.entrouvert.com'
|
|
395 |
|
|
396 |
items_info = [{'text': 'test item', 'amount': Decimal('10.00'), 'reference_id': ''}]
|
395 |
397 |
eopayment_mock.assert_called_once_with(
|
396 |
398 |
Decimal(10), email=user.email, first_name=user.first_name, last_name=user.last_name,
|
397 |
|
capture_date=capture_date)
|
|
399 |
capture_date=capture_date, merchant_name='Compte Citoyen', items_info=items_info
|
|
400 |
)
|
|
401 |
|
|
402 |
|
|
403 |
def test_basket_items_extra_info(app, user, user_name_id, regie, basket_page, monkeypatch):
|
|
404 |
url = '%s?NameId=%s' % (reverse('api-add-basket-item'), user_name_id)
|
|
405 |
items_info = [{'text': 'face mask', 'amount': Decimal(10), 'reference_id': '1'},
|
|
406 |
{'text': 'face mask 2', 'amount': Decimal(15), 'reference_id': '2'}]
|
|
407 |
items_post_data = [{'display_name': 'face mask', 'amount': 10, 'reference_id': 1},
|
|
408 |
{'display_name': 'face mask 2', 'amount': 15, 'reference_id': 2}]
|
|
409 |
global_title = 'FooBar'
|
|
410 |
|
|
411 |
url = sign_url(url, settings.LINGO_API_SIGN_KEY)
|
|
412 |
for item in items_post_data:
|
|
413 |
resp = app.post_json(url, params=item)
|
|
414 |
assert resp.status_code == 200
|
|
415 |
|
|
416 |
resp = login(app).get('/test_basket_cell/')
|
|
417 |
import eopayment
|
|
418 |
eopayment_mock = mock.Mock(
|
|
419 |
return_value=('orderid', eopayment.URL, 'http://dummy-payment.demo.entrouvert.com/'))
|
|
420 |
monkeypatch.setattr(eopayment.Payment, 'request', eopayment_mock)
|
|
421 |
with override_settings(TEMPLATE_VARS={'global_title': global_title}):
|
|
422 |
resp = resp.form.submit()
|
|
423 |
eopayment_mock.assert_called_once_with(
|
|
424 |
Decimal(25), email=user.email, first_name=user.first_name, last_name=user.last_name,
|
|
425 |
merchant_name=global_title, items_info=items_info
|
|
426 |
)
|
|
427 |
|
|
428 |
|
|
429 |
def test_basket_items_extra_info_no_basket(app, regie, basket_page, monkeypatch):
|
|
430 |
# when no user is authenticated, it is still possible to pass an email to eopayment backend
|
|
431 |
url = reverse('api-add-basket-item')
|
|
432 |
email = 'test@entrouvert.com'
|
|
433 |
items_info = [{'text': 'face mask', 'amount': Decimal(10), 'reference_id': ''}]
|
|
434 |
item = {'display_name': 'face mask', 'amount': 10, 'email': email}
|
|
435 |
|
|
436 |
url = sign_url(url, settings.LINGO_API_SIGN_KEY)
|
|
437 |
resp = app.post_json(url, params=item)
|
|
438 |
assert resp.status_code == 200
|
|
439 |
item = BasketItem.objects.first()
|
|
440 |
assert item.user is None
|
|
441 |
|
|
442 |
payment_url = resp.json['payment_url']
|
|
443 |
import eopayment
|
|
444 |
eopayment_mock = mock.Mock(
|
|
445 |
return_value=('orderid', eopayment.URL, 'http://dummy-payment.demo.entrouvert.com/'))
|
|
446 |
monkeypatch.setattr(eopayment.Payment, 'request', eopayment_mock)
|
|
447 |
resp = app.get(payment_url)
|
|
448 |
eopayment_mock.assert_called_once_with(
|
|
449 |
Decimal(10), email=email, first_name='', last_name='', items_info=items_info,
|
|
450 |
merchant_name='Compte Citoyen'
|
|
451 |
)
|
398 |
452 |
|
399 |
453 |
|
400 |
454 |
@pytest.mark.parametrize("invalid_capture_date", [8, '', 'not-a-date'])
|
401 |
|
-
|