Skip to content

Instantly share code, notes, and snippets.

@tanvirraj
Last active October 7, 2024 10:18
Show Gist options
  • Save tanvirraj/7a722a8c275b268b0094d995a748c226 to your computer and use it in GitHub Desktop.
Save tanvirraj/7a722a8c275b268b0094d995a748c226 to your computer and use it in GitHub Desktop.
@pytest.mark.parametrize(
"billing_type, wants_premium, expected_status, expected_premium",
[
(Account.BillingType.V1, True, 400, False),
(Account.BillingType.GIFT, True, 200, True),
],
)
def test_update_account_wanting_premium(
url,
client,
account_without_card,
billing_type,
wants_premium,
expected_status,
expected_premium,
):
account_without_card.billing_type = billing_type
account_without_card.save()
account_without_card.refresh_from_db()
payload = {
"username": account_without_card.username,
"notifications": account_without_card.notifications,
"billing_plan_status": account_without_card.billing_plan_status,
"billing_type": billing_type,
"id": str(account_without_card.id),
"wants_premium": wants_premium,
"user": account_without_card.user.id,
}
response = client.put(url, data=json.dumps(payload), content_type=CONTENT_TYPE)
assert response.status_code == expected_status
account_without_card.refresh_from_db()
assert account_without_card.wants_premium == expected_premium
assert account_without_card.is_premium == expected_premium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment