New membership and accounting apps (contains just models) #5
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ __pycache__/
|
|||
*.sw*
|
||||
db.sqlite3
|
||||
membersystem/settings/local.py
|
||||
.pytest_cache
|
||||
|
|
|
@ -9,3 +9,11 @@ To start developing:
|
|||
# Run this make target, which installs all the requirements and sets up a
|
||||
# development database.
|
||||
$ make dev-setup
|
||||
|
||||
To run the Django development server:
|
||||
|
||||
$ python manage.py runserver
|
||||
|
||||
Before you push your stuff, run tests:
|
||||
|
||||
$ make test
|
||||
|
|
|
@ -32,6 +32,7 @@ class Account(CreatedModifiedAbstract):
|
|||
|
||||
owner = models.ForeignKey(get_user_model(), on_delete=models.PROTECT)
|
||||
|
||||
@property
|
||||
def balance(self):
|
||||
return self.transactions.all().aggregate(Sum('amount')).get('amount', 0)
|
||||
|
||||
|
|
16
accounting/tests.py
Normal file
16
accounting/tests.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import pytest
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from . import models
|
||||
|
||||
# @pytest.fixture
|
||||
# def test():
|
||||
# do stuff
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_balance():
|
||||
user = User.objects.create_user("test", "lala@adas.com", "1234")
|
||||
account = models.Account.objects.create(
|
||||
owner=user
|
||||
)
|
||||
assert account.balance == 0
|
5
pytest.ini
Normal file
5
pytest.ini
Normal file
|
@ -0,0 +1,5 @@
|
|||
[pytest]
|
||||
testpaths = .
|
||||
python_files = tests.py test_*.py *_tests.py
|
||||
DJANGO_SETTINGS_MODULE = membersystem.settings
|
||||
#norecursedirs = dist tmp* .svn .*
|
|
@ -1,2 +1,3 @@
|
|||
pytest
|
||||
pytest-django
|
||||
pre-commit
|
||||
|
|
Loading…
Reference in a new issue