mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
New subscription type for jewels
New condition to consider floats in subscriptions
This commit is contained in:
parent
94582a2d96
commit
3be64d6a8f
@ -1365,15 +1365,8 @@ msgid "Notices"
|
|||||||
msgstr "Information"
|
msgstr "Information"
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:14
|
#: com/templates/com/news_admin_list.jinja:14
|
||||||
<<<<<<< 02b317eeb9274ad44a74856c412b3a2a0e8eda
|
|
||||||
msgid "Displayed notices"
|
msgid "Displayed notices"
|
||||||
msgstr "Informations affichées"
|
msgstr "Informations affichées"
|
||||||
=======
|
|
||||||
#, fuzzy
|
|
||||||
#| msgid "Legal notices"
|
|
||||||
msgid "Displayed notices"
|
|
||||||
msgstr "Mentions légales"
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:18
|
#: com/templates/com/news_admin_list.jinja:18
|
||||||
#: com/templates/com/news_admin_list.jinja:47
|
#: com/templates/com/news_admin_list.jinja:47
|
||||||
@ -1442,15 +1435,8 @@ msgid "Remove"
|
|||||||
msgstr "Retirer"
|
msgstr "Retirer"
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:43
|
#: com/templates/com/news_admin_list.jinja:43
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
msgid "Notices to moderate"
|
msgid "Notices to moderate"
|
||||||
msgstr "Informations à modérer"
|
msgstr "Informations à modérer"
|
||||||
=======
|
|
||||||
#, fuzzy
|
|
||||||
#| msgid "New files to be moderated"
|
|
||||||
msgid "Notices to moderate"
|
|
||||||
msgstr "Nouveaux fichiers à modérer"
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:72
|
#: com/templates/com/news_admin_list.jinja:72
|
||||||
msgid "Weeklies"
|
msgid "Weeklies"
|
||||||
@ -1458,11 +1444,7 @@ msgstr "Nouvelles hebdomadaires"
|
|||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:74
|
#: com/templates/com/news_admin_list.jinja:74
|
||||||
msgid "Displayed weeklies"
|
msgid "Displayed weeklies"
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
msgstr "Nouvelles hebdomadaires affichées"
|
msgstr "Nouvelles hebdomadaires affichées"
|
||||||
=======
|
|
||||||
msgstr ""
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:84
|
#: com/templates/com/news_admin_list.jinja:84
|
||||||
#: com/templates/com/news_admin_list.jinja:124
|
#: com/templates/com/news_admin_list.jinja:124
|
||||||
@ -1471,15 +1453,8 @@ msgid "Dates"
|
|||||||
msgstr "Dates"
|
msgstr "Dates"
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:115
|
#: com/templates/com/news_admin_list.jinja:115
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
msgid "Weeklies to moderate"
|
msgid "Weeklies to moderate"
|
||||||
msgstr "Nouvelles hebdomadaires à modérer"
|
msgstr "Nouvelles hebdomadaires à modérer"
|
||||||
=======
|
|
||||||
#, fuzzy
|
|
||||||
#| msgid "New files to be moderated"
|
|
||||||
msgid "Weeklies to moderate"
|
|
||||||
msgstr "Nouveaux fichiers à modérer"
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:156
|
#: com/templates/com/news_admin_list.jinja:156
|
||||||
msgid "Calls"
|
msgid "Calls"
|
||||||
@ -1487,21 +1462,11 @@ msgstr "Appels"
|
|||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:158
|
#: com/templates/com/news_admin_list.jinja:158
|
||||||
msgid "Displayed calls"
|
msgid "Displayed calls"
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
msgstr "Appels affichés"
|
msgstr "Appels affichés"
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:193
|
#: com/templates/com/news_admin_list.jinja:193
|
||||||
msgid "Calls to moderate"
|
msgid "Calls to moderate"
|
||||||
msgstr "Appels à modérer"
|
msgstr "Appels à modérer"
|
||||||
=======
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:193
|
|
||||||
#, fuzzy
|
|
||||||
#| msgid "is moderated"
|
|
||||||
msgid "Calls to moderate"
|
|
||||||
msgstr "est modéré"
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:228
|
#: com/templates/com/news_admin_list.jinja:228
|
||||||
msgid "Events"
|
msgid "Events"
|
||||||
@ -1509,21 +1474,11 @@ msgstr "Événements"
|
|||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:230
|
#: com/templates/com/news_admin_list.jinja:230
|
||||||
msgid "Displayed events"
|
msgid "Displayed events"
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
msgstr "Événements affichés"
|
msgstr "Événements affichés"
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:265
|
#: com/templates/com/news_admin_list.jinja:265
|
||||||
msgid "Events to moderate"
|
msgid "Events to moderate"
|
||||||
msgstr "Événements à modérer"
|
msgstr "Événements à modérer"
|
||||||
=======
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: com/templates/com/news_admin_list.jinja:265
|
|
||||||
#, fuzzy
|
|
||||||
#| msgid "is moderated"
|
|
||||||
msgid "Events to moderate"
|
|
||||||
msgstr "est modéré"
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
|
|
||||||
#: com/templates/com/news_detail.jinja:10
|
#: com/templates/com/news_detail.jinja:10
|
||||||
msgid "Back to news"
|
msgid "Back to news"
|
||||||
@ -4122,20 +4077,12 @@ msgid "Washing and drying"
|
|||||||
msgstr "Lavage et séchage"
|
msgstr "Lavage et séchage"
|
||||||
|
|
||||||
#: launderette/templates/launderette/launderette_book.jinja:27
|
#: launderette/templates/launderette/launderette_book.jinja:27
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
#: sith/settings.py:541
|
#: sith/settings.py:541
|
||||||
=======
|
|
||||||
#: sith/settings.py:544
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
msgid "Washing"
|
msgid "Washing"
|
||||||
msgstr "Lavage"
|
msgstr "Lavage"
|
||||||
|
|
||||||
#: launderette/templates/launderette/launderette_book.jinja:31
|
#: launderette/templates/launderette/launderette_book.jinja:31
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
#: sith/settings.py:541
|
#: sith/settings.py:541
|
||||||
=======
|
|
||||||
#: sith/settings.py:544
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
msgid "Drying"
|
msgid "Drying"
|
||||||
msgstr "Séchage"
|
msgstr "Séchage"
|
||||||
|
|
||||||
@ -4442,79 +4389,43 @@ msgstr "Membre de Sbarro ou de l'ESTA, 15 €"
|
|||||||
msgid "One semester Welcome Week"
|
msgid "One semester Welcome Week"
|
||||||
msgstr "Un semestre Welcome Week"
|
msgstr "Un semestre Welcome Week"
|
||||||
|
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
#: sith/settings.py:505
|
|
||||||
msgid "President"
|
|
||||||
msgstr "Président"
|
|
||||||
|
|
||||||
#: sith/settings.py:506
|
|
||||||
msgid "Vice-President"
|
|
||||||
msgstr "Vice-Président"
|
|
||||||
|
|
||||||
#: sith/settings.py:507
|
|
||||||
msgid "Treasurer"
|
|
||||||
msgstr "Trésorier"
|
|
||||||
|
|
||||||
#: sith/settings.py:508
|
|
||||||
msgid "Communication supervisor"
|
|
||||||
msgstr "Responsable communication"
|
|
||||||
|
|
||||||
#: sith/settings.py:509
|
|
||||||
msgid "Secretary"
|
|
||||||
msgstr "Secrétaire"
|
|
||||||
|
|
||||||
#: sith/settings.py:510
|
|
||||||
msgid "IT supervisor"
|
|
||||||
msgstr "Responsable info"
|
|
||||||
|
|
||||||
#: sith/settings.py:511
|
|
||||||
msgid "Board member"
|
|
||||||
msgstr "Membre du bureau"
|
|
||||||
|
|
||||||
#: sith/settings.py:512
|
|
||||||
msgid "Active member"
|
|
||||||
msgstr "Membre actif"
|
|
||||||
|
|
||||||
#: sith/settings.py:513
|
#: sith/settings.py:513
|
||||||
=======
|
|
||||||
#: sith/settings.py:487
|
|
||||||
msgid "Two month for free"
|
msgid "Two month for free"
|
||||||
msgstr "Deux mois gratuits"
|
msgstr "Deux mois gratuits"
|
||||||
|
|
||||||
#: sith/settings.py:509
|
#: sith/settings.py:510
|
||||||
msgid "President"
|
msgid "President"
|
||||||
msgstr "Président"
|
msgstr "Président"
|
||||||
|
|
||||||
#: sith/settings.py:510
|
#: sith/settings.py:511
|
||||||
msgid "Vice-President"
|
msgid "Vice-President"
|
||||||
msgstr "Vice-Président"
|
msgstr "Vice-Président"
|
||||||
|
|
||||||
#: sith/settings.py:511
|
#: sith/settings.py:512
|
||||||
msgid "Treasurer"
|
msgid "Treasurer"
|
||||||
msgstr "Trésorier"
|
msgstr "Trésorier"
|
||||||
|
|
||||||
#: sith/settings.py:512
|
#: sith/settings.py:513
|
||||||
msgid "Communication supervisor"
|
msgid "Communication supervisor"
|
||||||
msgstr "Responsable communication"
|
msgstr "Responsable communication"
|
||||||
|
|
||||||
#: sith/settings.py:513
|
#: sith/settings.py:514
|
||||||
msgid "Secretary"
|
msgid "Secretary"
|
||||||
msgstr "Secrétaire"
|
msgstr "Secrétaire"
|
||||||
|
|
||||||
#: sith/settings.py:514
|
#: sith/settings.py:515
|
||||||
msgid "IT supervisor"
|
msgid "IT supervisor"
|
||||||
msgstr "Responsable info"
|
msgstr "Responsable info"
|
||||||
|
|
||||||
#: sith/settings.py:515
|
#: sith/settings.py:516
|
||||||
msgid "Board member"
|
msgid "Board member"
|
||||||
msgstr "Membre du bureau"
|
msgstr "Membre du bureau"
|
||||||
|
|
||||||
#: sith/settings.py:516
|
#: sith/settings.py:517
|
||||||
msgid "Active member"
|
msgid "Active member"
|
||||||
msgstr "Membre actif"
|
msgstr "Membre actif"
|
||||||
|
|
||||||
#: sith/settings.py:517
|
#: sith/settings.py:517
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
msgid "Curious"
|
msgid "Curious"
|
||||||
msgstr "Curieux"
|
msgstr "Curieux"
|
||||||
|
|
||||||
@ -4538,47 +4449,38 @@ msgstr "Nouvelles photos/albums à modérer dans le SAS"
|
|||||||
msgid "You've been identified on some pictures"
|
msgid "You've been identified on some pictures"
|
||||||
msgstr "Vous avez été identifié sur des photos"
|
msgstr "Vous avez été identifié sur des photos"
|
||||||
|
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
#: sith/settings.py:558
|
||||||
#: sith/settings.py:553
|
|
||||||
=======
|
|
||||||
#: sith/settings.py:551
|
|
||||||
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "You just refilled of %s €"
|
msgid "You just refilled of %s €"
|
||||||
msgstr "Vous avez rechargé votre compte de %s €"
|
msgstr "Vous avez rechargé votre compte de %s €"
|
||||||
|
|
||||||
<<<<<<< 02b317eee8b9274ad44a74856c412b3a2a0e8eda
|
|
||||||
#: sith/settings.py:554
|
#: sith/settings.py:554
|
||||||
=======
|
|
||||||
#: sith/settings.py:552
|
|
||||||
#: sith/settings.py:556
|
|
||||||
>>>>>>> Free subscription for jewels
|
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "You just bought %s"
|
msgid "You just bought %s"
|
||||||
msgstr "Vous avez acheté %s"
|
msgstr "Vous avez acheté %s"
|
||||||
|
|
||||||
#: sith/settings.py:555
|
#: sith/settings.py:563
|
||||||
|
#: sith/settings.py:560
|
||||||
msgid "You have a notification"
|
msgid "You have a notification"
|
||||||
msgstr "Vous avez une notification"
|
msgstr "Vous avez une notification"
|
||||||
|
|
||||||
#: sith/settings.py:559
|
#: sith/settings.py:564
|
||||||
msgid "Success!"
|
msgid "Success!"
|
||||||
msgstr "Succès !"
|
msgstr "Succès !"
|
||||||
|
|
||||||
#: sith/settings.py:560
|
#: sith/settings.py:565
|
||||||
msgid "Fail!"
|
msgid "Fail!"
|
||||||
msgstr "Échec !"
|
msgstr "Échec !"
|
||||||
|
|
||||||
#: sith/settings.py:561
|
#: sith/settings.py:566
|
||||||
msgid "You successfully posted an article in the Weekmail"
|
msgid "You successfully posted an article in the Weekmail"
|
||||||
msgstr "Article posté avec succès dans le Weekmail"
|
msgstr "Article posté avec succès dans le Weekmail"
|
||||||
|
|
||||||
#: sith/settings.py:562
|
#: sith/settings.py:567
|
||||||
msgid "You successfully edited an article in the Weekmail"
|
msgid "You successfully edited an article in the Weekmail"
|
||||||
msgstr "Article édité avec succès dans le Weekmail"
|
msgstr "Article édité avec succès dans le Weekmail"
|
||||||
|
|
||||||
#: sith/settings.py:563
|
#: sith/settings.py:568
|
||||||
msgid "You successfully sent the Weekmail"
|
msgid "You successfully sent the Weekmail"
|
||||||
msgstr "Weekmail envoyé avec succès"
|
msgstr "Weekmail envoyé avec succès"
|
||||||
|
|
||||||
|
@ -484,10 +484,10 @@ SITH_SUBSCRIPTIONS = {
|
|||||||
'price': 0,
|
'price': 0,
|
||||||
'duration': 1,
|
'duration': 1,
|
||||||
},
|
},
|
||||||
'deux-mois-pour-bijoux': {
|
'deux-mois-essai': {
|
||||||
'name': _('Two month for free'),
|
'name': _('Two month for free'),
|
||||||
'price': 0,
|
'price': 0,
|
||||||
'duration': 0.34,
|
'duration': 0.33,
|
||||||
}
|
}
|
||||||
# To be completed....
|
# To be completed....
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class Subscription(models.Model):
|
|||||||
'sbarro/esta': 9,
|
'sbarro/esta': 9,
|
||||||
'cursus-alternant': 10,
|
'cursus-alternant': 10,
|
||||||
'welcome-semestre': 11,
|
'welcome-semestre': 11,
|
||||||
'un-mois': 12,
|
'deux-mois-essai': 12,
|
||||||
}
|
}
|
||||||
PAYMENT = {
|
PAYMENT = {
|
||||||
"CHECK": 1,
|
"CHECK": 1,
|
||||||
@ -169,11 +169,11 @@ class Subscription(models.Model):
|
|||||||
start = Subscription.compute_start(duration=duration)
|
start = Subscription.compute_start(duration=duration)
|
||||||
# This can certainly be simplified, but it works like this
|
# This can certainly be simplified, but it works like this
|
||||||
try:
|
try:
|
||||||
return start.replace(month=int((start.month - 1 + 6 * duration) % 12 + 1),
|
return start.replace(month=int(round((start.month - 1 + 6 * duration) % 12 + 1, 0)),
|
||||||
year=int(start.year + int(duration / 2) + (1 if start.month > 6 and duration % 2 == 1 else 0)))
|
year=int(round(start.year + int(duration / 2) + (1 if int(start.month + 6 * duration) > 12 and (duration % 2 == 1 or duration < 1) else 0), 0)))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return start.replace(day=1, month=int((start.month + 6 * duration) % 12 + 1),
|
return start.replace(day=1, month=int(round((start.month + 6 * duration) % 12 + 1, 0)),
|
||||||
year=int(start.year + int(duration / 2) + (1 if start.month > 6 and duration % 2 == 1 else 0)))
|
year=int(round(start.year + int(duration / 2) + (1 if int(start.month + 6 * duration) > 12 and (duration % 2 == 1 or duration < 1) else 0), 0)))
|
||||||
|
|
||||||
def can_be_edited_by(self, user):
|
def can_be_edited_by(self, user):
|
||||||
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root
|
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root
|
||||||
|
@ -26,16 +26,23 @@ from unittest import mock
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from subscription.models import Subscription
|
from subscription.models import Subscription
|
||||||
|
from core.models import User
|
||||||
|
from django.conf import settings
|
||||||
|
from datetime import datetime
|
||||||
|
from django.core.management import call_command
|
||||||
|
|
||||||
|
|
||||||
class FakeDate(date):
|
class FakeDate(date):
|
||||||
"""A fake replacement for date that can be mocked for testing."""
|
"""A fake replacement for date that can be mocked for testing."""
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
return date.__new__(date, *args, **kwargs)
|
return date.__new__(date, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def date_mock_today(year, month, day):
|
def date_mock_today(year, month, day):
|
||||||
FakeDate.today = classmethod(lambda cls: date(year, month, day))
|
FakeDate.today = classmethod(lambda cls: date(year, month, day))
|
||||||
|
|
||||||
class SubscribtionTest(TestCase):
|
|
||||||
|
class SubscriptionTest(TestCase):
|
||||||
|
|
||||||
@mock.patch('subscription.models.date', FakeDate)
|
@mock.patch('subscription.models.date', FakeDate)
|
||||||
def test_start_dates_sliding_without_start(self):
|
def test_start_dates_sliding_without_start(self):
|
||||||
@ -46,9 +53,9 @@ class SubscribtionTest(TestCase):
|
|||||||
|
|
||||||
def test_start_dates_sliding_with_start(self):
|
def test_start_dates_sliding_with_start(self):
|
||||||
self.assertTrue(Subscription.compute_start(date(2015, 5, 17), 1) ==
|
self.assertTrue(Subscription.compute_start(date(2015, 5, 17), 1) ==
|
||||||
date(2015, 5, 17))
|
date(2015, 5, 17))
|
||||||
self.assertTrue(Subscription.compute_start(date(2015, 5, 17), 2) ==
|
self.assertTrue(Subscription.compute_start(date(2015, 5, 17), 2) ==
|
||||||
date(2015, 5, 17))
|
date(2015, 5, 17))
|
||||||
|
|
||||||
@mock.patch('subscription.models.date', FakeDate)
|
@mock.patch('subscription.models.date', FakeDate)
|
||||||
def test_start_dates_not_sliding_without_start(self):
|
def test_start_dates_not_sliding_without_start(self):
|
||||||
@ -60,10 +67,8 @@ class SubscribtionTest(TestCase):
|
|||||||
self.assertTrue(Subscription.compute_start(duration=4) == date(2015, 8, 15))
|
self.assertTrue(Subscription.compute_start(duration=4) == date(2015, 8, 15))
|
||||||
|
|
||||||
def test_start_dates_not_sliding_with_start(self):
|
def test_start_dates_not_sliding_with_start(self):
|
||||||
self.assertTrue(Subscription.compute_start(date(2015, 5, 17), 3) ==
|
self.assertTrue(Subscription.compute_start(date(2015, 5, 17), 3) == date(2015, 2, 15))
|
||||||
date(2015, 2, 15))
|
self.assertTrue(Subscription.compute_start(date(2015, 1, 11), 3) == date(2014, 8, 15))
|
||||||
self.assertTrue(Subscription.compute_start(date(2015, 1, 11), 3) ==
|
|
||||||
date(2014, 8, 15))
|
|
||||||
|
|
||||||
@mock.patch('subscription.models.date', FakeDate)
|
@mock.patch('subscription.models.date', FakeDate)
|
||||||
def test_end_dates_sliding(self):
|
def test_end_dates_sliding(self):
|
||||||
@ -81,9 +86,54 @@ class SubscribtionTest(TestCase):
|
|||||||
d = Subscription.compute_end(duration=4)
|
d = Subscription.compute_end(duration=4)
|
||||||
self.assertTrue(d == date(2017, 8, 15))
|
self.assertTrue(d == date(2017, 8, 15))
|
||||||
|
|
||||||
|
@mock.patch('subscription.models.date', FakeDate)
|
||||||
|
def test_end_dates_with_float(self):
|
||||||
|
date_mock_today(2015, 9, 18)
|
||||||
|
d = Subscription.compute_end(duration=0.33)
|
||||||
|
self.assertTrue(d == date(2015, 11, 18))
|
||||||
|
d = Subscription.compute_end(duration=0.67)
|
||||||
|
self.assertTrue(d == date(2016, 1, 18))
|
||||||
|
d = Subscription.compute_end(duration=0.5)
|
||||||
|
self.assertTrue(d == date(2015, 12, 18))
|
||||||
|
|
||||||
def test_end_dates_not_sliding_with_start(self):
|
def test_end_dates_not_sliding_with_start(self):
|
||||||
d = Subscription.compute_end(duration=3, start=date(2015, 9, 18))
|
d = Subscription.compute_end(duration=3, start=date(2015, 9, 18))
|
||||||
self.assertTrue(d == date(2017, 3, 18))
|
self.assertTrue(d == date(2017, 3, 18))
|
||||||
d = Subscription.compute_end(duration=4, start=date(2015, 9, 18))
|
d = Subscription.compute_end(duration=4, start=date(2015, 9, 18))
|
||||||
self.assertTrue(d == date(2017, 9, 18))
|
self.assertTrue(d == date(2017, 9, 18))
|
||||||
|
|
||||||
|
|
||||||
|
class DecimalDurationTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
call_command("populate")
|
||||||
|
self.user = User.objects.filter(username="public").first()
|
||||||
|
|
||||||
|
def test_duration_two_months(self):
|
||||||
|
|
||||||
|
s = Subscription(member=User.objects.filter(pk=self.user.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
||||||
|
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
|
||||||
|
s.subscription_start = date(2017, 8, 29)
|
||||||
|
s.subscription_end = s.compute_end(duration=0.33,
|
||||||
|
start=s.subscription_start)
|
||||||
|
s.save()
|
||||||
|
self.assertTrue(s.subscription_end == date(2017, 10, 29))
|
||||||
|
|
||||||
|
def test_duration_three_months(self):
|
||||||
|
|
||||||
|
s = Subscription(member=User.objects.filter(pk=self.user.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
||||||
|
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
|
||||||
|
s.subscription_start = date(2017, 8, 29)
|
||||||
|
s.subscription_end = s.compute_end(duration=0.5,
|
||||||
|
start=s.subscription_start)
|
||||||
|
s.save()
|
||||||
|
self.assertTrue(s.subscription_end == date(2017, 11, 29))
|
||||||
|
|
||||||
|
def test_duration_four_months(self):
|
||||||
|
|
||||||
|
s = Subscription(member=User.objects.filter(pk=self.user.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[3],
|
||||||
|
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
|
||||||
|
s.subscription_start = date(2017, 8, 29)
|
||||||
|
s.subscription_end = s.compute_end(duration=0.67,
|
||||||
|
start=s.subscription_start)
|
||||||
|
s.save()
|
||||||
|
self.assertTrue(s.subscription_end == date(2017, 12, 29))
|
||||||
|
Loading…
Reference in New Issue
Block a user