-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #766 from WesternFriend/subscription-view-tests
Subscription webhook view tests
- Loading branch information
Showing
5 changed files
with
223 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.contrib.auth import get_user_model | ||
|
||
import factory | ||
from factory.django import DjangoModelFactory | ||
|
||
|
||
class UserFactory(DjangoModelFactory): | ||
class Meta: | ||
model = get_user_model() | ||
|
||
email = factory.Faker("email") | ||
is_staff = factory.Faker("pybool") | ||
is_active = factory.Faker("pybool") |
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,45 @@ | ||
import factory | ||
from factory.django import DjangoModelFactory | ||
from factory.fuzzy import FuzzyInteger, FuzzyDate, FuzzyChoice | ||
from django.utils.timezone import now, timedelta | ||
from subscription.models import ( | ||
MagazineFormatChoices, | ||
MagazinePriceGroupChoices, | ||
Subscription, | ||
) | ||
|
||
from accounts.factories import UserFactory | ||
|
||
|
||
class SubscriptionFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Subscription | ||
|
||
magazine_format = FuzzyChoice(MagazineFormatChoices.values) | ||
price_group = FuzzyChoice(MagazinePriceGroupChoices.values) | ||
price = FuzzyInteger(0, 100) | ||
recurring = factory.Faker("pybool") | ||
start_date = FuzzyDate( | ||
start_date=now().date() - timedelta(days=365), | ||
end_date=now().date(), | ||
) | ||
end_date = FuzzyDate( | ||
start_date=now().date(), | ||
end_date=now().date() + timedelta(days=365), | ||
) | ||
subscriber_given_name = factory.Faker("first_name") | ||
subscriber_family_name = factory.Faker("last_name") | ||
subscriber_organization = factory.Faker("company") | ||
subscriber_street_address = factory.Faker("street_address") | ||
subscriber_street_address_line_2 = factory.Faker("secondary_address") | ||
subscriber_postal_code = factory.Faker("postcode") | ||
subscriber_address_locality = factory.Faker("city") | ||
subscriber_address_region = factory.Faker("state") | ||
subscriber_address_country = factory.Faker("country") | ||
|
||
user = factory.SubFactory(UserFactory) | ||
paid = factory.Faker("pybool") | ||
|
||
braintree_subscription_id = factory.Sequence( | ||
lambda n: f"braintree_subscription_id_{n}", | ||
) |
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
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