Skip to content

Commit

Permalink
Add TestMinibc
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwecan committed Mar 8, 2024
1 parent e388dd8 commit 25c7c96
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 3 deletions.
4 changes: 1 addition & 3 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,7 @@ def test_minibc_cmd_find_missing_shipping(
):
_ = app.config["BIGCOMMERCE_MEMBERSHIP_SKUS"]
_ = mocker.patch("member_card.commands.Minibc")
_ = mocker.patch(
"member_card.commands.find_missing_shipping"
)
_ = mocker.patch("member_card.commands.find_missing_shipping")
result = runner.invoke(
cli=minibc,
args=["find-missing-shipping"],
Expand Down
102 changes: 102 additions & 0 deletions tests/test_minibc.py
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

0 comments on commit 25c7c96

Please sign in to comment.