adamcharnock / django-hordak

Double entry accounting in Django
http://django-hordak.readthedocs.io
MIT License
228 stars 55 forks source link

Remove hard dependency on psycopg2 #109

Closed angusholder closed 6 months ago

angusholder commented 7 months ago

Currently, using hordak as a library requires having psycopg2 installed, but only for a few imports in some migrations that use django.contrib.postgres.fields.jsonb.JSONField. Since Django 3.2 (hordak's min supported Django ver), django.contrib.postgres.fields.jsonb.JSONField has been effectively an alias to django.db.models.JSONField (see here), so I believe it's safe to change these migrated fields to the non-postgres-specific django.db.models.JSONField.

I ran the tests on my machine locally, and all passed except two, but those two have nothing to do with the database. Might be a locale issue on my machine? I'm hoping all the tests will pass on CI.

Test results
======================================================================                        
ERROR: test_fees (hordak.tests.utilities.test_currency.CurrencyExchangeTestCase)              
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\proj\django-hordak\hordak\tests\utilities\test_currency.py", line 376, in test_fees
    currency_exchange(
  File "C:\proj\django-hordak\hordak\utilities\currency.py", line 197, in currency_exchange
    or "Exchange of {} to {}, incurring {} fees".format(
  File "C:\proj\django-hordak\venv\lib\site-packages\moneyed\classes.py", line 203, in __str__
    return format_money(self)
  File "C:\proj\django-hordak\venv\lib\site-packages\moneyed\l10n.py", line 23, in format_money
    return babel_format_currency(  # type: ignore[no-any-return]
  File "C:\proj\django-hordak\venv\lib\site-packages\babel\numbers.py", line 664, in format_currency
    locale = Locale.parse(locale)
  File "C:\proj\django-hordak\venv\lib\site-packages\babel\core.py", line 328, in parse
    raise TypeError(f"Unexpected value for identifier: {identifier!r}")
TypeError: Unexpected value for identifier: None
                                                                                           raise TypeError(f"Unexpected value for identifier: {identifier!r}")
TypeError: Unexpected value for identifier: None

======================================================================
ERROR: test_peter_selinger_tutorial_table_4_4 (hordak.tests.utilities.test_currency.CurrencyExchangeTestCase)
Test the example given by Peter Selinger in his muticurrency accounting tutorial. Table 4.4
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\proj\django-hordak\hordak\tests\utilities\test_currency.py", line 342, in test_peter_selinger_tutorial_table_4_4
    currency_exchange(
  File "C:\proj\django-hordak\hordak\utilities\currency.py", line 197, in currency_exchange
    or "Exchange of {} to {}, incurring {} fees".format(
  File "C:\proj\django-hordak\venv\lib\site-packages\moneyed\classes.py", line 203, in __str__
    return format_money(self)
  File "C:\proj\django-hordak\venv\lib\site-packages\moneyed\l10n.py", line 23, in format_money
    return babel_format_currency(  # type: ignore[no-any-return]
  File "C:\proj\django-hordak\venv\lib\site-packages\babel\numbers.py", line 664, in format_currency
    locale = Locale.parse(locale)
  File "C:\proj\django-hordak\venv\lib\site-packages\babel\core.py", line 328, in parse
    raise TypeError(f"Unexpected value for identifier: {identifier!r}")
TypeError: Unexpected value for identifier: None

----------------------------------------------------------------------
Ran 229 tests in 18.339s

FAILED (errors=2)
PetrDlouhy commented 6 months ago

@angusholder The tests on the master are now passing, could you please rebase?

angusholder commented 6 months ago

@PetrDlouhy Okay, I've rebased!

PetrDlouhy commented 6 months ago

@angusholder Thanks, this seems simple and nice.