Add some tests

This commit is contained in:
Raphael Michel
2019-10-18 13:08:25 +02:00
parent a1c7a6f2b0
commit f8433b5cc9
10 changed files with 555 additions and 15 deletions

View File

@@ -156,6 +156,12 @@ def taxrule(event):
return event.tax_rules.create(name="VAT", rate=19)
@pytest.fixture
@scopes_disabled()
def taxrule0(event):
return event.tax_rules.create(name="VAT", rate=0)
@pytest.fixture
@scopes_disabled()
def taxrule2(event2):

View File

@@ -463,6 +463,75 @@ def test_item_create_with_variation(token_client, organizer, event, item, catego
assert new_item.variations.first().value.localize('en') == "Comment"
@pytest.mark.django_db
def test_item_create_giftcard_validation(token_client, organizer, event, item, category, category2, taxrule, taxrule0):
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/items/'.format(organizer.slug, event.slug),
{
"category": category.pk,
"name": {
"en": "Ticket"
},
"active": True,
"description": None,
"default_price": "23.00",
"free_price": False,
"tax_rate": "19.00",
"tax_rule": taxrule0.pk,
"admission": True,
"issue_giftcard": True,
"position": 0,
"picture": None,
"available_from": None,
"available_until": None,
"require_voucher": False,
"hide_without_voucher": False,
"allow_cancel": True,
"min_per_order": None,
"max_per_order": None,
"checkin_attention": False,
"has_variations": True,
"addons": []
},
format='json'
)
assert resp.status_code == 400
assert resp.content.decode() == '{"non_field_errors":["Gift card products should not be admission products at the same time."]}'
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/items/'.format(organizer.slug, event.slug),
{
"category": category.pk,
"name": {
"en": "Ticket"
},
"active": True,
"description": None,
"default_price": "23.00",
"free_price": False,
"tax_rate": "19.00",
"tax_rule": taxrule.pk,
"admission": False,
"issue_giftcard": True,
"position": 0,
"picture": None,
"available_from": None,
"available_until": None,
"require_voucher": False,
"hide_without_voucher": False,
"allow_cancel": True,
"min_per_order": None,
"max_per_order": None,
"checkin_attention": False,
"has_variations": True,
"addons": []
},
format='json'
)
assert resp.status_code == 400
assert resp.content.decode() == '{"non_field_errors":["Gift card products should not be associated with non-zero ' \
'tax rates since sales tax will be applied when the gift card is redeemed."]}'
@pytest.mark.django_db
def test_item_create_with_addon(token_client, organizer, event, item, category, category2, taxrule):
resp = token_client.post(