subscription: rename test

Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
Skia 2017-09-07 01:27:49 +02:00
parent 2f912a197c
commit 96d0ae36be

View File

@ -102,6 +102,21 @@ class SubscriptionTest(TestCase):
d = Subscription.compute_end(duration=4, start=date(2015, 9, 18))
self.assertTrue(d == date(2017, 9, 18))
@mock.patch('subscription.models.date', FakeDate)
def test_dates_sliding_with_subscribed_user(self):
user = User.objects.filter(pk=self.user.pk).first()
s = Subscription(member=user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
s.subscription_start = date(2015, 8, 29)
s.subscription_end = s.compute_end(duration=2,
start=s.subscription_start)
s.save()
self.assertTrue(s.subscription_end == date(2016, 8, 29))
date_mock_today(2016, 8, 25)
d = Subscription.compute_end(duration=2,
user=user)
self.assertTrue(d == date(2017, 8, 29))
class DecimalDurationTest(TestCase):
def setUp(self):
@ -138,23 +153,3 @@ class DecimalDurationTest(TestCase):
s.save()
self.assertTrue(s.subscription_end == date(2017, 12, 29))
class SpecialCasesOfSubscription(TestCase):
def setUp(self):
call_command("populate")
self.user = User.objects.filter(username="public").first()
@mock.patch('subscription.models.date', FakeDate)
def test_subscription_before_end_of_actual_one(self):
user = User.objects.filter(pk=self.user.pk).first()
s = Subscription(member=user, subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
s.subscription_start = date(2015, 8, 29)
s.subscription_end = s.compute_end(duration=2,
start=s.subscription_start)
s.save()
self.assertTrue(s.subscription_end == date(2016, 8, 29))
date_mock_today(2016, 8, 25)
d = Subscription.compute_end(duration=2,
user=user)
self.assertTrue(d == date(2017, 8, 29))