Esempio n. 1
0
def test_reverse_whole_session():
    session = cashdesk_session_before_factory()
    pp = preorder_position_factory(paid=True)
    trans = transaction_factory(session)
    transaction_position_factory(transaction=trans, product=product_factory(items=True))
    pos = redeem_preorder_ticket(secret=pp.secret)
    pos.transaction = trans
    pos.save()
    assert is_redeemed(pp)
    reverse_session(session)
    assert not is_redeemed(pp)
Esempio n. 2
0
def test_redeemed_entry_by_sale():
    list_constraint = list_constraint_factory()
    entry = list_constraint_entry_factory(list_constraint, redeemed=False)
    TransactionPosition.objects.create(
        type='sell', listentry=entry,
        value=Decimal('12.00'), tax_rate=Decimal('0.00'), tax_value=Decimal('0.00'),
        product=product_factory(), transaction=transaction_factory()
    )
    assert is_redeemed(entry)
Esempio n. 3
0
def test_simple_valid():
    pp = preorder_position_factory(paid=True, redeemed=False)
    pos = redeem_preorder_ticket(secret=pp.secret)
    assert isinstance(pos, TransactionPosition)
    assert pos.value == Decimal('0.00')
    assert pos.product == pp.product
    pos.transaction = transaction_factory()
    pos.save()
    assert is_redeemed(pp)
Esempio n. 4
0
def test_reversed_preorder():
    pp = preorder_position_factory(paid=True)
    t1 = TransactionPosition.objects.create(
        type='redeem', preorder_position=pp,
        value=Decimal('0.00'), tax_rate=Decimal('0.00'), tax_value=Decimal('0.00'),
        product=product_factory(), transaction=transaction_factory()
    )
    TransactionPosition.objects.create(
        type='reverse', preorder_position=pp, reverses=t1,
        value=Decimal('0.00'), tax_rate=Decimal('0.00'), tax_value=Decimal('0.00'),
        product=product_factory(), transaction=transaction_factory()
    )
    assert not is_redeemed(pp)
Esempio n. 5
0
def test_reversed_entry():
    list_constraint = list_constraint_factory()
    entry = list_constraint_entry_factory(list_constraint)
    t1 = TransactionPosition.objects.create(
        type='redeem', listentry=entry,
        value=Decimal('0.00'), tax_rate=Decimal('0.00'), tax_value=Decimal('0.00'),
        product=product_factory(), transaction=transaction_factory()
    )
    TransactionPosition.objects.create(
        type='reverse', listentry=entry, reverses=t1,
        value=Decimal('0.00'), tax_rate=Decimal('0.00'), tax_value=Decimal('0.00'),
        product=product_factory(), transaction=transaction_factory()
    )
    assert not is_redeemed(entry)
Esempio n. 6
0
def test_success(api_with_session, event_settings):
    pp = preorder_position_factory(paid=True)
    secret = pp.secret
    req = {
        'positions': [
            {
                'type': 'redeem',
                'secret': secret
            }
        ]
    }
    response = api_with_session.post('/api/transactions/', req, format='json')
    assert response.status_code == 201
    j = json.loads(response.content.decode())
    assert j['success']
    assert j['positions'][0]['success']
    assert is_redeemed(pp)
Esempio n. 7
0
def test_warning_constraint_bypass_success(api_with_session, event_settings):
    pp = preorder_position_factory(paid=True)
    warning_constraint = warning_constraint_factory()
    WarningConstraintProduct.objects.create(
        product=pp.product, constraint=warning_constraint, price=65
    )
    req = {
        'positions': [
            {
                'type': 'redeem',
                'secret': pp.secret,
                'bypass_price': '65.00'
            }
        ]
    }
    response = api_with_session.post('/api/transactions/', req, format='json')
    assert response.status_code == 201
    j = json.loads(response.content.decode())
    assert j['success']
    assert j['positions'][0]['success']
    assert is_redeemed(pp)
Esempio n. 8
0
def test_preorder_list_constraint_success(api_with_session):
    pp = preorder_position_factory(paid=True)
    list_constraint = list_constraint_factory()
    entry = list_constraint_entry_factory(list_constraint=list_constraint, redeemed=False)
    ListConstraintProduct.objects.create(
        product=pp.product, constraint=entry.list,
    )
    req = {
        'positions': [
            {
                'type': 'redeem',
                'list_{}'.format(entry.list.pk): str(entry.identifier),
                'secret': pp.secret
            }
        ]
    }
    response = api_with_session.post('/api/transactions/', req, format='json')
    assert response.status_code == 201
    j = json.loads(response.content.decode())
    assert j['success']
    assert j['positions'][0]['success']
    assert is_redeemed(entry)
Esempio n. 9
0
def test_unredeemed_preorder():
    pp = preorder_position_factory(paid=True, redeemed=False)
    assert not is_redeemed(pp)
Esempio n. 10
0
def test_unredeemed_entry():
    list_constraint = list_constraint_factory()
    entry = list_constraint_entry_factory(list_constraint, redeemed=False)
    assert not is_redeemed(entry)
Esempio n. 11
0
def test_redeemed_entry():
    list_constraint = list_constraint_factory()
    entry = list_constraint_entry_factory(list_constraint, redeemed=True)
    assert is_redeemed(entry)
Esempio n. 12
0
 def is_redeemed(self) -> bool:
     from postix.core.utils.checks import is_redeemed
     return is_redeemed(self)