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

TransactionModel UnitTests #186

Merged

Conversation

PieterCK
Copy link
Contributor

@PieterCK PieterCK commented Feb 27, 2024

Added new helper functions to quickly create a number of randomly populated journal entry, ledger, account and transactions in DjangoLedgerTest .
Added unit tests for:

  • TransactionModelForm
  • TransactionModelFormSet
  • get_transactionmodel_formset_class()

image

@PieterCK PieterCK changed the title Test: Added utility methods to DjangoBaseTestCase and unit tests related to TransactionModel Test: Added utility methods to DjangoLedgerTest and unit tests related to TransactionModel Feb 28, 2024
@elarroba elarroba self-assigned this Feb 29, 2024
@elarroba elarroba self-requested a review March 1, 2024 04:10
Copy link
Member

@elarroba elarroba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is is the right approach for writing unit tests.
I'd like to see more tests geared towards testing the application logic and not the core Django functionality itself.

For instance, instead of testing if formsets are working the way they're intended (which is a Django-spefific test), we should be focusing on the TransactionModel business logic itself.

For example:
- Testing if amounts could be saved as negative transactions (which they shouldn't).
- Testing if a TransactionModel can be modified when Journal Entry is locked.
- Role and Account validity for certain situations.
- If testing forms, will a Formset allow the user to modify a transaction from a locked journal entry?
- If locked journal entry, are the form fields properly greyed out in the UI to show that transactions can't be modified.

These are just examples of business logic that needs unit tests.
I will gladly accept your contribution and modify it accordingly.

@elarroba elarroba changed the title Test: Added utility methods to DjangoLedgerTest and unit tests related to TransactionModel TransactionModel UnitTests Mar 6, 2024
@elarroba elarroba merged commit 634b5f5 into arrobalytics:develop Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants