Skip to content

Commit

Permalink
Remove now-unnecessary db fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
hrichards committed Aug 27, 2024
1 parent bc5e5fc commit b091857
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from capone.tests.factories import UserFactory


def test_transaction_fields(db):
def test_transaction_fields():
"""
Test filtering by `posted_timestamp`, `notes`, `type`, and `user`.
"""
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_transaction_fields(db):
)


def test_no_matches(db):
def test_no_matches():
"""
No matching transaction raises DoesNotExist.
"""
Expand All @@ -71,7 +71,7 @@ def test_no_matches(db):
)


def test_multiple_matches(db):
def test_multiple_matches():
"""
Multiple matching transactions raises MultipleObjectsReturned.
"""
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_multiple_matches(db):
)


def test_mismatch_on_ledger_entries(db):
def test_mismatch_on_ledger_entries():
"""
An otherwise matching Trans. will fail if its LedgerEntries mismatch.
"""
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_mismatch_on_ledger_entries(db):
)


def test_mismatch_on_evidence(db):
def test_mismatch_on_evidence():
"""
An otherwise matching Trans. will fail if its evidence is different.
"""
Expand Down
14 changes: 7 additions & 7 deletions capone/tests/test_create_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@pytest.fixture
def create_objects(db):
def create_objects():
user = UserFactory()
accounts_receivable = LedgerFactory(name='Accounts Receivable')
cash_unrecon = LedgerFactory(name='Cash (unreconciled)')
Expand Down Expand Up @@ -219,7 +219,7 @@ def test_no_ledger_entries(create_objects):
validate_transaction(user)


def test_with_existing_ledger_entry(db):
def test_with_existing_ledger_entry():
amount = D(100)
user = UserFactory()

Expand Down Expand Up @@ -293,26 +293,26 @@ def _create_transaction_and_compare_to_amount(
assert entry2.amount == -amount


def test_precision(db):
def test_precision():
_create_transaction_and_compare_to_amount(
D('-499.9999'))


def test_round_up(db):
def test_round_up():
_create_transaction_and_compare_to_amount(
D('499.99995'), D('500'))


def test_round_down(db):
def test_round_down():
_create_transaction_and_compare_to_amount(
D('499.99994'), D('499.9999'))


def test_round_up_negative(db):
def test_round_up_negative():
_create_transaction_and_compare_to_amount(
D('-499.99994'), D('-499.9999'))


def test_round_down_negative(db):
def test_round_down_negative():
_create_transaction_and_compare_to_amount(
D('-499.99995'), D('-500'))
4 changes: 2 additions & 2 deletions capone/tests/test_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@pytest.fixture
def credit_card_transaction(db):
def credit_card_transaction():
return CreditCardTransactionFactory()


Expand Down Expand Up @@ -61,7 +61,7 @@ def test_custom_ledger_entries(credit_card_transaction):
)


def test_custom_evidence(db):
def test_custom_evidence():
ccx = CreditCardTransactionFactory()
TransactionFactory(evidence=[ccx])

Expand Down
14 changes: 5 additions & 9 deletions capone/tests/test_filter_by_related_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


@pytest.fixture
def create_transactions(db):
def create_transactions():
create_user = UserFactory()
ledger = LedgerFactory()

Expand Down Expand Up @@ -90,7 +90,7 @@ def _create_transaction_with_evidence(evidence):
(MatchType.EXACT, 'none'),
])
def test_filter_with_no_evidence(
match_type, queryset_function_name, create_transactions, db,
match_type, queryset_function_name, create_transactions,
):
"""
Method returns correct Transactions with no evidence given.
Expand All @@ -109,7 +109,7 @@ def test_filter_with_no_evidence(
(MatchType.NONE, [False, False, False, True, False]),
(MatchType.EXACT, [True, False, False, False, False]),
])
def test_filters(match_type, results, create_transactions, db):
def test_filters(match_type, results, create_transactions):
"""
Method returns correct Transactions with various evidence given.
Expand Down Expand Up @@ -156,11 +156,7 @@ def test_filters(match_type, results, create_transactions, db):
(MatchType.EXACT, 4),
])
def test_query_counts(
match_type,
query_counts,
django_assert_num_queries,
create_transactions,
db,
match_type, query_counts, django_assert_num_queries, create_transactions,
):
"""
`filter_by_related_objects` should use a constant number of queries.
Expand All @@ -187,7 +183,7 @@ def test_invalid_match_type():
Transaction.objects.filter_by_related_objects(match_type='foo')


def test_chaining_filter_to_existing_queryset(create_transactions, db):
def test_chaining_filter_to_existing_queryset(create_transactions):
"""
`filter_by_related_objects` can be used like any other queryset filter.
"""
Expand Down
4 changes: 2 additions & 2 deletions capone/tests/test_ledger_balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


@pytest.fixture
def create_objects(db):
def create_objects():
order_1, order_2 = OrderFactory.create_batch(2)
ar_ledger = LedgerFactory(name='A/R')
cash_ledger = LedgerFactory(name='Cash')
Expand Down Expand Up @@ -270,7 +270,7 @@ def add_transaction(orders):
)


def test_ledger_balances_filtering(db, create_objects):
def test_ledger_balances_filtering(create_objects):
(
order_1,
order_2,
Expand Down
10 changes: 5 additions & 5 deletions capone/tests/test_transaction_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from capone.tests.factories import UserFactory


def test_unicode_methods(db):
def test_unicode_methods():
"""
Test all __str__ methods.
"""
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_unicode_methods(db):
)


def test_transaction_summary(db):
def test_transaction_summary():
"""
Test that Transaction.summary returns correct information.
"""
Expand All @@ -81,15 +81,15 @@ def test_transaction_summary(db):
}


def test_setting_explicit_timestamp_field(db):
def test_setting_explicit_timestamp_field():
transaction = TransactionFactory()
old_posted_timestamp = transaction.posted_timestamp
transaction.posted_timestamp = timezone.now()
transaction.save()
assert old_posted_timestamp != transaction.posted_timestamp


def test_editing_transactions(db):
def test_editing_transactions():
"""
Test that validation is still done when editing a Transaction.
Expand All @@ -110,7 +110,7 @@ def test_editing_transactions(db):
transaction.save()


def test_non_void(db):
def test_non_void():
"""
Test Transaction.objects.non_void filter.
"""
Expand Down
2 changes: 1 addition & 1 deletion capone/tests/test_void.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


@pytest.fixture
def create_objects(db):
def create_objects():
creation_user = UserFactory()
ar_ledger = LedgerFactory()
rev_ledger = LedgerFactory()
Expand Down

0 comments on commit b091857

Please sign in to comment.