tests: add basic test of update_transactions command
This commit is contained in:
parent
9ca3e7377a
commit
04b830d9ee
|
@ -1,3 +1,4 @@
|
|||
import eopayment
|
||||
import pytest
|
||||
from datetime import datetime, timedelta
|
||||
import urlparse
|
||||
|
@ -9,11 +10,13 @@ from django.contrib.auth.models import User
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from webtest import TestApp
|
||||
|
||||
from django.test import Client
|
||||
|
||||
from combo.apps.lingo.models import Regie, BasketItem, Transaction, RemoteItem
|
||||
from combo.apps.lingo.models import Regie, BasketItem, Transaction, RemoteItem, EXPIRED
|
||||
from combo.apps.lingo.management.commands.update_transactions import Command as UpdateTransactionsCommand
|
||||
from combo.utils import sign_url
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
@ -197,3 +200,17 @@ def test_nonexisting_transaction(regie, user):
|
|||
callback_url = reverse('lingo-callback', kwargs={'regie_pk': regie.id})
|
||||
get_resp = client.get(callback_url, data)
|
||||
assert get_resp.status_code == 404
|
||||
|
||||
def test_transaction_expiration():
|
||||
t1 = Transaction(status=0)
|
||||
t1.save()
|
||||
t1.start_date = timezone.now() - timedelta(hours=2)
|
||||
t1.save()
|
||||
t2 = Transaction(status=0)
|
||||
t2.save()
|
||||
|
||||
cmd = UpdateTransactionsCommand()
|
||||
cmd.handle()
|
||||
|
||||
assert Transaction.objects.get(id=t1.id).status == EXPIRED
|
||||
assert Transaction.objects.get(id=t2.id).status == 0
|
||||
|
|
Loading…
Reference in New Issue