Commit c8aee250 authored by Maxime Emschwiller's avatar Maxime Emschwiller
Browse files

refacto(backend): refacto test so that they work with refactored computing functions

parent 63164bd7
......@@ -17,7 +17,7 @@ class StatsConnectionsTest(TestCase):
username=f"{i}", defaults=dict(last_login=yesterday)
)
daily_connections = get_daily_connections()
daily_connections = get_daily_connections(yesterday)
self.assertEqual(daily_connections, 10)
two_days_ago = today - timedelta(days=2)
......@@ -26,7 +26,7 @@ class StatsConnectionsTest(TestCase):
username=f"{i}", defaults=dict(last_login=two_days_ago)
)
daily_connections = get_daily_connections()
daily_connections = get_daily_connections(yesterday)
self.assertEqual(daily_connections, 10)
def test_update_daily_connections(self):
......
......@@ -13,8 +13,8 @@ from stats_app.utils import get_today_as_datetime, get_contributions_profiles
class StatsContributionsTest(TestCase):
@classmethod
def setUpTestData(cls):
today = get_today_as_datetime()
yesterday = today - timedelta(days=1)
cls.today = get_today_as_datetime()
cls.yesterday = cls.today - timedelta(days=1)
cls.univ = get_dummy_university()
utc_partner_id = cls.univ.corresponding_utc_partners.all()[0].utc_id
......@@ -40,12 +40,12 @@ class StatsContributionsTest(TestCase):
ExchangeFeedback.objects.update_or_create(
exchange=exchange,
defaults=dict(
updated_on=yesterday, untouched=False, university=cls.univ
updated_on=cls.yesterday, untouched=False, university=cls.univ
),
)
def test_get_contributions_profiles(self):
daily_contributions_profiles = get_contributions_profiles()
daily_contributions_profiles = get_contributions_profiles(self.yesterday)
self.assertEqual(len(daily_contributions_profiles), 2)
for p in daily_contributions_profiles:
self.assertEqual(p.major, "IM")
......@@ -54,11 +54,11 @@ class StatsContributionsTest(TestCase):
self.assertEqual(p.university_pk, self.univ.pk)
def test_update_daily_exchange_contributions_info(self):
today = get_today_as_datetime()
yesterday = today - timedelta(days=1)
update_daily_exchange_contributions_info()
contributions = DailyExchangeContributionsInfo.objects.filter(date=yesterday)
contributions = DailyExchangeContributionsInfo.objects.filter(
date=self.yesterday
)
self.assertEqual(len(contributions), 1)
contribution: DailyExchangeContributionsInfo = contributions[0]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment