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 from requirements.txt #27

Merged
merged 30 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5df50f6
Remove enum34 from requirements.txt
hrichards Aug 26, 2024
0666930
Remove Python 2 compatibility code
hrichards Aug 26, 2024
7b8783d
Update deprecated import
hrichards Aug 26, 2024
5925dce
Fix bug in 4.2: can't access related managers if no PK
hrichards Aug 26, 2024
60e2ccf
Update to new import path
hrichards Aug 26, 2024
131f509
Unpin dependencies
hrichards Aug 26, 2024
8cc99b2
Update setup.cfg settings format
hrichards Aug 26, 2024
255f36e
Update changelog
hrichards Aug 27, 2024
a613137
Add more Python and Django versions
hrichards Aug 26, 2024
868a4bd
Add supported Python versions
hrichards Aug 26, 2024
603dd2b
Use django.utils.timezone
hrichards Aug 26, 2024
366139f
Work around bug in psycopg2==2.9
hrichards Aug 27, 2024
c8de8ce
Bump Postgres for later Django versions
hrichards Aug 27, 2024
0b07f61
Silence expected runtime warnings
hrichards Aug 27, 2024
fd7e9c3
Only enable running versions for now
hrichards Aug 27, 2024
3eb8ad8
Convert test suite to Pytest-style
hrichards Aug 27, 2024
bc5e5fc
Parametrize test suite on USE_TZ
hrichards Aug 27, 2024
b091857
Remove now-unnecessary db fixture
hrichards Aug 27, 2024
ade8eb3
Remove copypasta
hrichards Aug 27, 2024
df9b245
Remove virtualenv
hrichards Aug 27, 2024
4dd9a12
Fix passenv formatting
hrichards Aug 27, 2024
724f449
Reformat passenv
hrichards Aug 27, 2024
749e05c
Revert "Only enable running versions for now"
hrichards Aug 27, 2024
6579c41
Add other versions separately
hrichards Aug 27, 2024
9179ebf
Rework pytest calls and silence datetime warning
hrichards Aug 27, 2024
2254bf7
Update setup.cfg
hrichards Aug 28, 2024
a406fa1
Add `wheel` to setup_requires
hrichards Aug 28, 2024
3d635f6
Pin wheel
hrichards Aug 28, 2024
28e2a7c
Skip missing interpreters
hrichards Aug 28, 2024
716aac6
Sem-ver: feature
hrichards Aug 28, 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
8 changes: 2 additions & 6 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

services:
postgres:
image: postgres:9.6
image: postgres:12
env:
POSTGRES_USER: django
POSTGRES_PASSWORD: django
Expand All @@ -31,18 +31,14 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.6]
python-version: [3.6, 3.8, 3.9]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
pip install virtualenv
npm i pg
- name: Run Tests
run: |
make test
Expand Down
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ VENDOR_SENTINEL:=.sentinel
venv: $(VENV_ACTIVATE)

$(VENV_ACTIVATE): requirements*.txt
test -f $@ || virtualenv --python=python3.6 $(VENV_DIR)
test -f $@ || python -m venv $(VENV_DIR)
$(WITH_VENV) pip install -r requirements-setup.txt
$(WITH_VENV) pip install -e .
$(WITH_VENV) pip install -r requirements-dev.txt
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