-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
from conftest import create_fake_user | ||
from mock import sentinel | ||
|
||
from member_card import minibc | ||
from member_card.db import db | ||
from member_card.models import AnnualMembership, User | ||
|
||
if TYPE_CHECKING: | ||
from flask import Flask | ||
from pytest_mock.plugin import MockerFixture | ||
from requests_mock.contrib.fixture import Fixture as RequestsMockFixture | ||
|
||
from member_card.models import MembershipCard | ||
|
||
|
||
@pytest.fixture() | ||
def mock_subscriptions(): | ||
return [ | ||
{ | ||
"id": 1022, | ||
"order_id": 500001, | ||
"customer": { | ||
"id": 501, | ||
"first_name": "John", | ||
"last_name": "Doe", | ||
"email": "john.doe@example.com", | ||
}, | ||
"payment_method": { | ||
"id": 13741, | ||
"method": "credit_card", | ||
"gateway_customer_id": "cus_N1GU7Jp2t2naNp", | ||
"token": "pm_1M6i3aC5ywMMwynHtHWUbsDz", | ||
"credit_card": { | ||
"type": "Visa", | ||
"last_digits": "string", | ||
"expiry_month": 7, | ||
"expiry_year": 2024, | ||
}, | ||
"billing_address": { | ||
"first_name": "John", | ||
"last_name": "Jones", | ||
"street_1": "200 Yorkland Blvd.", | ||
"street_2": "Unit 210", | ||
"city": "Toronto", | ||
"state": "Ontario", | ||
"country_iso2": "CA", | ||
"zip": "M2J5C1", | ||
}, | ||
"config_id": 122, | ||
}, | ||
"products": [ | ||
{ | ||
"store_product_id": 4002, | ||
"order_product_id": 12901, | ||
"name": "T-Shirt of the Month", | ||
"sku": "TEST-001", | ||
"options": [ | ||
{ | ||
"option_id": 43, | ||
"value": "112", | ||
"display_name": "Size", | ||
"display_value": "M", | ||
} | ||
], | ||
"quantity": 2, | ||
"price": 6.49, | ||
"total": 12.98, | ||
} | ||
], | ||
"periodicity": {"frequency": 1, "unit": "month"}, | ||
"subtotal": 12.98, | ||
"shipping_cost": 5, | ||
"total": 17.98, | ||
"status": "active", | ||
"shipping_address": { | ||
"street_1": "200 Yorkland Blvd.", | ||
"street_2": "Unit 210", | ||
"city": "Toronto", | ||
"state": "Ontario", | ||
"country_iso2": "CA", | ||
"zip": "M2J5C1,", | ||
"shipping_method": "Free Shipping", | ||
}, | ||
"signup_date": "string", | ||
"pause_date": "string", | ||
"cancellation_date": "string", | ||
"next_payment_date": "2022-05-12", | ||
"created_time": "string", | ||
"last_modified": "string", | ||
} | ||
] | ||
|
||
|
||
def test_parse_subscriptions(app: "Flask", mock_subscriptions, mocker): | ||
with app.app_context(): | ||
returned_subscriptions = minibc.parse_subscriptions( | ||
subscriptions=mock_subscriptions | ||
) | ||
assert len(returned_subscriptions) == 1 |