Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove enum34, convert to Pytest-style, add more supported targets #25

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
87d9b78
Remove enum34 from requirements.txt
hrichards Aug 26, 2024
29452ad
Remove Python 2 compatibility code
hrichards Aug 26, 2024
691ed01
Update deprecated import
hrichards Aug 26, 2024
eb0a8ab
Fix bug in 4.2: can't access related managers if no PK
hrichards Aug 26, 2024
c3dd8f2
Update to new import path
hrichards Aug 26, 2024
34931af
Unpin dependencies
hrichards Aug 26, 2024
7f1ab92
Add more Python and Django versions
hrichards Aug 26, 2024
d72f8ab
Update setup.cfg settings format
hrichards Aug 26, 2024
8e0c74f
Use django.utils.timezone
hrichards Aug 26, 2024
19f738c
Add supported Python versions
hrichards Aug 26, 2024
bb23955
Work around bug in psycopg2==2.9
hrichards Aug 26, 2024
4be96ed
Parametrize test suite on USE_TZ
hrichards Aug 27, 2024
c7e4efa
Remove now-unnecessary db fixture
hrichards Aug 27, 2024
ca78ff4
Update changelog
hrichards Aug 27, 2024
30f1251
Remove unused import
hrichards Aug 27, 2024
2fea40c
Sem-ver: feature
hrichards Aug 27, 2024
3f3eacd
Update GHA
hrichards Aug 27, 2024
7ea6cad
New GHA version
hrichards Aug 27, 2024
341f45b
Fix GHA
hrichards Aug 27, 2024
15af0b7
Fix GHA
hrichards Aug 27, 2024
7966763
Temp.ly delete lint
hrichards Aug 27, 2024
f1c7ec6
Revert "Temp.ly delete lint"
hrichards Aug 27, 2024
73b8895
Fix GHA
hrichards Aug 27, 2024
2162366
Fix virtualenvs
hrichards Aug 27, 2024
f818b30
Fix virtualenvs
hrichards Aug 27, 2024
83c50a0
Fix tox.ini
hrichards Aug 27, 2024
f838368
Fix tox envs
hrichards Aug 27, 2024
01a430b
Bump Postgres
hrichards Aug 27, 2024
55da50b
Add gh-actions section
hrichards Aug 27, 2024
159199a
Remove coverage report stuff
hrichards Aug 27, 2024
efc51b2
Is append the culprit?
hrichards Aug 27, 2024
255f6a9
Rework pytest calls and silence datetime warning
hrichards Aug 27, 2024
c541508
Run coverage everywhere
hrichards Aug 27, 2024
78b6068
Remove 3.10 from 3.6 target
hrichards Aug 27, 2024
39de08f
Bump Postgres again
hrichards Aug 27, 2024
6c1726c
Add back PG dependency?
hrichards Aug 27, 2024
8727a32
Reindent
hrichards Aug 27, 2024
9c8e5a9
Temp.ly delete others
hrichards Aug 27, 2024
c16ab7e
Add extra hosts
hrichards Aug 27, 2024
3b83b4d
Revert "Add extra hosts"
hrichards Aug 27, 2024
f8f505a
Change host
hrichards Aug 27, 2024
b795985
Revert all changes to django.yml
hrichards Aug 27, 2024
c39d1e2
Remove py36 special cases
hrichards Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
3.6
3.8
3.9
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# 3.1.0

- No functional changes: added support targets and refactored tests and dependencies.

## Major

- Support Django 3.2 and 4.2.
- Add support for Python 3.8 and 3.9.
- Cope with psycopg2 bug: only 2.8 is supported through Django 2.2, but 2.9 is supported for higher Django versions.
- Parameterize test suite on USE_TZ to confirm Capone works for both True and False.
- Remove unneeded dependency `enum34`.
- Refactor to use `django.utils.timezone`.

## Minor

- Convert tests to Pytest style.
- Default in tests to USE_TZ == True.
- Remove remaining Python 2 compatibility shims.
- Unpin lots of test dependencies.

# 3.0.0

- Drop Django < 1.11 support.
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ clean:
find . -name __pycache__ -delete
rm -f MANIFEST
rm -f test.db
rm -f xunit.xml
find . -type f -name '*.pyc' -delete
rm -rf coverage .coverage*
dropdb --if-exists capone_test_db -U postgres
Expand Down
17 changes: 6 additions & 11 deletions capone/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Q
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from capone.exceptions import TransactionBalanceException

Expand All @@ -20,7 +19,6 @@
NEGATIVE_DEBITS_HELP_TEXT = "Amount for this entry. Debits are negative, and credits are positive." # noqa: E501


@python_2_unicode_compatible
class TransactionRelatedObject(models.Model):
"""
A piece of evidence for a particular Transaction.
Expand Down Expand Up @@ -164,7 +162,6 @@ def filter_by_related_objects(
raise ValueError("Invalid match_type.")


@python_2_unicode_compatible
class TransactionType(models.Model):
"""
A user-defined "type" to group `Transactions`.
Expand Down Expand Up @@ -202,7 +199,6 @@ def get_or_create_manual_transaction_type_id():
return get_or_create_manual_transaction_type().id


@python_2_unicode_compatible
class Transaction(models.Model):
"""
The main model for representing a financial event in `capone`.
Expand Down Expand Up @@ -267,10 +263,11 @@ def validate(self):
Instead, the only check that makes sense is that the entries for the
transaction still balance.
"""
total = sum([entry.amount for entry in self.entries.all()])
if total != Decimal(0):
raise TransactionBalanceException(
"Credits do not equal debits. Mis-match of %s." % total)
if self.pk:
total = sum([entry.amount for entry in self.entries.all()])
if total != Decimal(0):
raise TransactionBalanceException(
"Credits do not equal debits. Mis-match of %s." % total)
return True

def save(self, **kwargs):
Expand All @@ -292,7 +289,6 @@ def summary(self):
}


@python_2_unicode_compatible
class Ledger(models.Model):
"""
A group of `LedgerEntries` all debiting or crediting the same resource.
Expand Down Expand Up @@ -368,7 +364,6 @@ def __str__(self):
amount=self.amount, ledger=self.ledger.name)


@python_2_unicode_compatible
class LedgerBalance(models.Model):
"""
A Denormalized balance for a related object in a ledger.
Expand Down
10 changes: 5 additions & 5 deletions capone/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from capone.tests.models import Order


class UserFactory(factory.DjangoModelFactory):
class UserFactory(factory.django.DjangoModelFactory):
"""
Factory for django.contrib.auth.get_user_model()

Expand All @@ -27,7 +27,7 @@ class Meta:
email = username = factory.Sequence(lambda n: "TransactionUser #%s" % n)


class LedgerFactory(factory.DjangoModelFactory):
class LedgerFactory(factory.django.DjangoModelFactory):
class Meta:
model = Ledger

Expand All @@ -36,22 +36,22 @@ class Meta:
number = factory.Sequence(lambda n: n)


class OrderFactory(factory.DjangoModelFactory):
class OrderFactory(factory.django.DjangoModelFactory):
class Meta:
model = Order

patient_name = factory.Sequence(lambda n: "Patient %s" % n)
barcode = factory.Sequence(lambda n: str(n))


class CreditCardTransactionFactory(factory.DjangoModelFactory):
class CreditCardTransactionFactory(factory.django.DjangoModelFactory):
class Meta:
model = CreditCardTransaction

cardholder_name = factory.Sequence(lambda n: "Cardholder %s" % n)


class TransactionTypeFactory(factory.DjangoModelFactory):
class TransactionTypeFactory(factory.django.DjangoModelFactory):
class Meta:
model = TransactionType

Expand Down
2 changes: 2 additions & 0 deletions capone/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@
'django.contrib.messages.middleware.MessageMiddleware',
)
SESSION_ENGINE = 'django.contrib.sessions.backends.db'

USE_TZ = True
Loading
Loading