New membership and accounting apps (contains just models) #5

Merged
benjaoming merged 6 commits from benjaoming/membersystem:membership_stuff into master 2019-08-31 16:55:27 +00:00
7 changed files with 32 additions and 0 deletions
Showing only changes of commit 056ca430ef - Show all commits

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ __pycache__/
*.sw* *.sw*
db.sqlite3 db.sqlite3
membersystem/settings/local.py membersystem/settings/local.py
.pytest_cache

View file

@ -9,3 +9,11 @@ To start developing:
# Run this make target, which installs all the requirements and sets up a # Run this make target, which installs all the requirements and sets up a
# development database. # development database.
$ make dev-setup $ make dev-setup
To run the Django development server:
$ python manage.py runserver
Before you push your stuff, run tests:
$ make test

View file

@ -32,6 +32,7 @@ class Account(CreatedModifiedAbstract):
owner = models.ForeignKey(get_user_model(), on_delete=models.PROTECT) owner = models.ForeignKey(get_user_model(), on_delete=models.PROTECT)
@property
def balance(self): def balance(self):
return self.transactions.all().aggregate(Sum('amount')).get('amount', 0) return self.transactions.all().aggregate(Sum('amount')).get('amount', 0)

View file

16
accounting/tests.py Normal file
View 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
View file

@ -0,0 +1,5 @@
[pytest]
testpaths = .
python_files = tests.py test_*.py *_tests.py
DJANGO_SETTINGS_MODULE = membersystem.settings
#norecursedirs = dist tmp* .svn .*

View file

@ -1,2 +1,3 @@
pytest pytest
pytest-django
pre-commit pre-commit