Skip to content

Commit

Permalink
Merge pull request #629 from makerspace/emaus/fix-transaction
Browse files Browse the repository at this point in the history
Fix error in 0b2834e
  • Loading branch information
emanuelen5 authored Jan 28, 2025
2 parents 2f0e43a + e20059c commit ad4ba0e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/src/shop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Transaction(Base):
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)

member: Mapped[Member] = relationship(Member)
stripe_pending: Mapped[Optional["StripePending"]] = relationship("StripePending")
stripe_pending: Mapped[list["StripePending"]] = relationship("StripePending")

def __repr__(self) -> str:
return f"Transaction(id={self.id}, amount={self.amount}, status={self.status}, created_at={self.created_at})"
Expand Down
29 changes: 29 additions & 0 deletions api/src/shop/test/transactions_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from decimal import Decimal

import membership.models
import shop.models
from service.db import db_session
from shop.transactions import get_source_transaction
from test_aid.test_base import FlaskTestBase


class ShopDataTest(FlaskTestBase):
models = [membership.models, shop.models]

def test_finds_transaction_for_stripe_pending(self) -> None:
member = self.db.create_member()
transaction = self.db.create_transaction(
member_id=member.member_id,
amount=Decimal("50"),
status=shop.models.Transaction.PENDING,
)
pending = shop.models.StripePending(
transaction_id=transaction.id,
stripe_token="stripe_token",
)
db_session.add(pending)
db_session.commit()

found_transaction = get_source_transaction("stripe_token")
self.assertIsNotNone(found_transaction)
self.assertEqual(transaction.id, found_transaction.id)

0 comments on commit ad4ba0e

Please sign in to comment.