Simple test: we can query the account-read page
This commit is contained in:
parent
74135f8877
commit
3a69c3371f
1 changed files with 57 additions and 0 deletions
57
kfet/tests/test_views.py
Normal file
57
kfet/tests/test_views.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
from django.test import TestCase, Client
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from ..models import Account, OperationGroup, Checkout, Operation
|
||||||
|
|
||||||
|
|
||||||
|
class AccountTests(TestCase):
|
||||||
|
"""Account related views"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# A user and its account
|
||||||
|
self.user = User.objects.create_user(username="foobar", password="foo")
|
||||||
|
acc = Account.objects.create(
|
||||||
|
trigramme="FOO", cofprofile=self.user.profile
|
||||||
|
)
|
||||||
|
|
||||||
|
# Dummy operations and operation groups
|
||||||
|
checkout = Checkout.objects.create(
|
||||||
|
created_by=acc, name="checkout",
|
||||||
|
valid_from=timezone.now(),
|
||||||
|
valid_to=timezone.now() + timezone.timedelta(days=365)
|
||||||
|
)
|
||||||
|
opeg_data = [
|
||||||
|
(timezone.now(), Decimal('10')),
|
||||||
|
(timezone.now() - timezone.timedelta(days=3), Decimal('3')),
|
||||||
|
]
|
||||||
|
OperationGroup.objects.bulk_create([
|
||||||
|
OperationGroup(
|
||||||
|
on_acc=acc, checkout=checkout, at=at, is_cof=False,
|
||||||
|
amount=amount
|
||||||
|
)
|
||||||
|
for (at, amount) in opeg_data
|
||||||
|
])
|
||||||
|
self.operation_groups = OperationGroup.objects.order_by("-amount")
|
||||||
|
Operation.objects.create(
|
||||||
|
group=self.operation_groups[0],
|
||||||
|
type=Operation.PURCHASE,
|
||||||
|
amount=Decimal('10')
|
||||||
|
)
|
||||||
|
Operation.objects.create(
|
||||||
|
group=self.operation_groups[1],
|
||||||
|
type=Operation.PURCHASE,
|
||||||
|
amount=Decimal('3')
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_account_read(self):
|
||||||
|
"""We can query the "Accout - Read" page."""
|
||||||
|
client = Client()
|
||||||
|
self.assertTrue(client.login(
|
||||||
|
username="foobar",
|
||||||
|
password="foo"
|
||||||
|
))
|
||||||
|
resp = client.get("/k-fet/accounts/FOO")
|
||||||
|
self.assertEqual(200, resp.status_code)
|
Loading…
Reference in a new issue