def test_create_from_product_id(self, price_create_mock, product_retrieve_mock): fake_price = deepcopy(FAKE_PRICE) fake_price["unit_amount"] /= 100 assert isinstance(fake_price["product"], str) price = Price.create(**fake_price) expected_create_kwargs = deepcopy(FAKE_PRICE) expected_create_kwargs["api_key"] = STRIPE_SECRET_KEY price_create_mock.assert_called_once_with(**expected_create_kwargs) self.assert_fks(price, expected_blank_fks={"djstripe.Customer.coupon"})
def test_create_from_djstripe_product(self, price_create_mock, product_retrieve_mock): fake_price = deepcopy(FAKE_PRICE) fake_price["product"] = Product.sync_from_stripe_data( self.stripe_product) fake_price["unit_amount"] /= 100 assert isinstance(fake_price["product"], Product) price = Price.create(**fake_price) price_create_mock.assert_called_once_with(api_key=STRIPE_SECRET_KEY, **FAKE_PRICE) self.assert_fks(price, expected_blank_fks={"djstripe.Customer.coupon"})
def test_create_with_metadata(self, price_create_mock, product_retrieve_mock): metadata = {"other_data": "more_data"} fake_price = deepcopy(FAKE_PRICE) fake_price["unit_amount"] /= 100 fake_price["metadata"] = metadata assert isinstance(fake_price["product"], str) price = Price.create(**fake_price) expected_create_kwargs = deepcopy(FAKE_PRICE) expected_create_kwargs["metadata"] = metadata price_create_mock.assert_called_once_with(api_key=STRIPE_SECRET_KEY, **expected_create_kwargs) self.assert_fks(price, expected_blank_fks={"djstripe.Customer.coupon"})