mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
write command test
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django.conf import settings
|
||||
from django.utils.timezone import now
|
||||
from django.utils.timezone import localdate, now
|
||||
from model_bakery import seq
|
||||
from model_bakery.recipe import Recipe, related
|
||||
|
||||
@ -11,13 +12,13 @@ from subscription.models import Subscription
|
||||
|
||||
active_subscription = Recipe(
|
||||
Subscription,
|
||||
subscription_start=now() - timedelta(days=30),
|
||||
subscription_end=now() + timedelta(days=30),
|
||||
subscription_start=localdate() - timedelta(days=30),
|
||||
subscription_end=localdate() + timedelta(days=30),
|
||||
)
|
||||
ended_subscription = Recipe(
|
||||
Subscription,
|
||||
subscription_start=now() - timedelta(days=60),
|
||||
subscription_end=now() - timedelta(days=30),
|
||||
subscription_start=localdate() - timedelta(days=60),
|
||||
subscription_end=localdate() - timedelta(days=30),
|
||||
)
|
||||
|
||||
subscriber_user = Recipe(
|
||||
@ -36,6 +37,17 @@ old_subscriber_user = Recipe(
|
||||
)
|
||||
"""A user with an ended subscription."""
|
||||
|
||||
__inactivity = localdate() - settings.SITH_ACCOUNT_INACTIVITY_DELTA
|
||||
very_old_subscriber_user = old_subscriber_user.extend(
|
||||
subscriptions=related(
|
||||
ended_subscription.extend(
|
||||
subscription_start=__inactivity - relativedelta(months=6, days=1),
|
||||
subscription_end=__inactivity - relativedelta(days=1),
|
||||
)
|
||||
)
|
||||
)
|
||||
"""A user which subscription ended enough time ago to be considered as inactive."""
|
||||
|
||||
ae_board_membership = Recipe(
|
||||
Membership,
|
||||
start_date=now() - timedelta(days=30),
|
||||
|
@ -7,12 +7,15 @@ from django.test import Client, TestCase
|
||||
from django.urls import reverse
|
||||
from django.utils.timezone import now
|
||||
from model_bakery import baker, seq
|
||||
from model_bakery.recipe import Recipe, related
|
||||
from model_bakery.recipe import Recipe
|
||||
|
||||
from core.baker_recipes import old_subscriber_user, subscriber_user
|
||||
from core.baker_recipes import (
|
||||
old_subscriber_user,
|
||||
subscriber_user,
|
||||
very_old_subscriber_user,
|
||||
)
|
||||
from core.models import User
|
||||
from counter.models import Counter, Refilling, Selling
|
||||
from subscription.models import Subscription
|
||||
|
||||
|
||||
class TestSearchUsers(TestCase):
|
||||
@ -121,9 +124,6 @@ class TestFilterInactive(TestCase):
|
||||
def setUpTestData(cls):
|
||||
time_active = now() - settings.SITH_ACCOUNT_INACTIVITY_DELTA + timedelta(days=1)
|
||||
time_inactive = time_active - timedelta(days=3)
|
||||
very_old_subscriber = old_subscriber_user.extend(
|
||||
subscriptions=related(Recipe(Subscription, subscription_end=time_inactive))
|
||||
)
|
||||
counter, seller = baker.make(Counter), baker.make(User)
|
||||
sale_recipe = Recipe(
|
||||
Selling,
|
||||
@ -137,7 +137,7 @@ class TestFilterInactive(TestCase):
|
||||
baker.make(User),
|
||||
subscriber_user.make(),
|
||||
old_subscriber_user.make(),
|
||||
*very_old_subscriber.make(_quantity=3),
|
||||
*very_old_subscriber_user.make(_quantity=3),
|
||||
]
|
||||
sale_recipe.make(customer=cls.users[3].customer, date=time_active)
|
||||
baker.make(
|
||||
|
Reference in New Issue
Block a user