mirror of
https://github.com/ae-utbm/sith3.git
synced 2024-06-01 04:19:43 +00:00
Move test into core/tests
This commit is contained in:
parent
9f08e17961
commit
45c8e1d3e7
|
@ -15,7 +15,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from datetime import timedelta
|
from datetime import date, timedelta
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
@ -26,6 +26,7 @@ from django.utils.timezone import now
|
||||||
from club.models import Membership
|
from club.models import Membership
|
||||||
from core.models import User, Group, Page, AnonymousUser
|
from core.models import User, Group, Page, AnonymousUser
|
||||||
from core.markdown import markdown
|
from core.markdown import markdown
|
||||||
|
from core.utils import get_start_of_semester
|
||||||
from sith import settings
|
from sith import settings
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -617,3 +618,28 @@ class UserIsInGroupTest(TestCase):
|
||||||
returns False
|
returns False
|
||||||
"""
|
"""
|
||||||
self.assertFalse(self.skia.is_in_group(name="This doesn't exist"))
|
self.assertFalse(self.skia.is_in_group(name="This doesn't exist"))
|
||||||
|
|
||||||
|
|
||||||
|
class UtilsTest(TestCase):
|
||||||
|
def test_get_start_of_semester(self):
|
||||||
|
autumn_month, autumn_day = settings.SITH_SEMESTER_START_AUTUMN
|
||||||
|
spring_month, spring_day = settings.SITH_SEMESTER_START_SPRING
|
||||||
|
|
||||||
|
t1_autumn_day = date(2025, 1, 1)
|
||||||
|
t2_autumn_day = date(2024, 9, 1)
|
||||||
|
|
||||||
|
t1_spring_day = date(2023, 3, 1)
|
||||||
|
t2_spring_day = date(2023, spring_month, spring_day)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
get_start_of_semester(t1_autumn_day), date(2024, autumn_month, autumn_day)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
get_start_of_semester(t2_autumn_day), date(2024, autumn_month, autumn_day)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
get_start_of_semester(t1_spring_day), date(2023, spring_month, spring_day)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
get_start_of_semester(t2_spring_day), date(2023, spring_month, spring_day)
|
||||||
|
)
|
||||||
|
|
|
@ -26,9 +26,7 @@ from django.utils.timezone import timedelta
|
||||||
|
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
from core.models import User
|
from core.models import User
|
||||||
from core.utils import get_start_of_semester
|
|
||||||
from counter.models import Counter, Customer, BillingInfo, Permanency, Selling, Product
|
from counter.models import Counter, Customer, BillingInfo, Permanency, Selling, Product
|
||||||
from django.conf import settings
|
|
||||||
from sith.settings import SITH_MAIN_CLUB
|
from sith.settings import SITH_MAIN_CLUB
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,29 +261,6 @@ class CounterStatsTest(TestCase):
|
||||||
s.customer = root_customer
|
s.customer = root_customer
|
||||||
s.save(allow_negative=True)
|
s.save(allow_negative=True)
|
||||||
|
|
||||||
def test_get_start_of_semester(self):
|
|
||||||
autumn_month, autumn_day = settings.SITH_SEMESTER_START_AUTUMN
|
|
||||||
spring_month, spring_day = settings.SITH_SEMESTER_START_SPRING
|
|
||||||
|
|
||||||
t1_autumn_day = date(2025, 1, 1)
|
|
||||||
t2_autumn_day = date(2024, 9, 1)
|
|
||||||
|
|
||||||
t1_spring_day = date(2023, 3, 1)
|
|
||||||
t2_spring_day = date(2023, spring_month, spring_day)
|
|
||||||
|
|
||||||
self.assertTrue(
|
|
||||||
get_start_of_semester(t1_autumn_day) == date(2024, autumn_month, autumn_day)
|
|
||||||
)
|
|
||||||
self.assertTrue(
|
|
||||||
get_start_of_semester(t2_autumn_day) == date(2024, autumn_month, autumn_day)
|
|
||||||
)
|
|
||||||
self.assertTrue(
|
|
||||||
get_start_of_semester(t1_spring_day) == date(2023, spring_month, spring_day)
|
|
||||||
)
|
|
||||||
self.assertTrue(
|
|
||||||
get_start_of_semester(t2_spring_day) == date(2023, spring_month, spring_day)
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_not_authenticated_user_fail(self):
|
def test_not_authenticated_user_fail(self):
|
||||||
# Test with not login user
|
# Test with not login user
|
||||||
response = self.client.get(reverse("counter:stats", args=[self.counter.id]))
|
response = self.client.get(reverse("counter:stats", args=[self.counter.id]))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user