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): ...@@ -17,7 +17,7 @@ class StatsConnectionsTest(TestCase):
username=f"{i}", defaults=dict(last_login=yesterday) username=f"{i}", defaults=dict(last_login=yesterday)
) )
daily_connections = get_daily_connections() daily_connections = get_daily_connections(yesterday)
self.assertEqual(daily_connections, 10) self.assertEqual(daily_connections, 10)
two_days_ago = today - timedelta(days=2) two_days_ago = today - timedelta(days=2)
...@@ -26,7 +26,7 @@ class StatsConnectionsTest(TestCase): ...@@ -26,7 +26,7 @@ class StatsConnectionsTest(TestCase):
username=f"{i}", defaults=dict(last_login=two_days_ago) 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) self.assertEqual(daily_connections, 10)
def test_update_daily_connections(self): def test_update_daily_connections(self):
......
...@@ -13,8 +13,8 @@ from stats_app.utils import get_today_as_datetime, get_contributions_profiles ...@@ -13,8 +13,8 @@ from stats_app.utils import get_today_as_datetime, get_contributions_profiles
class StatsContributionsTest(TestCase): class StatsContributionsTest(TestCase):
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
today = get_today_as_datetime() cls.today = get_today_as_datetime()
yesterday = today - timedelta(days=1) cls.yesterday = cls.today - timedelta(days=1)
cls.univ = get_dummy_university() cls.univ = get_dummy_university()
utc_partner_id = cls.univ.corresponding_utc_partners.all()[0].utc_id utc_partner_id = cls.univ.corresponding_utc_partners.all()[0].utc_id
...@@ -40,12 +40,12 @@ class StatsContributionsTest(TestCase): ...@@ -40,12 +40,12 @@ class StatsContributionsTest(TestCase):
ExchangeFeedback.objects.update_or_create( ExchangeFeedback.objects.update_or_create(
exchange=exchange, exchange=exchange,
defaults=dict( 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): 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) self.assertEqual(len(daily_contributions_profiles), 2)
for p in daily_contributions_profiles: for p in daily_contributions_profiles:
self.assertEqual(p.major, "IM") self.assertEqual(p.major, "IM")
...@@ -54,11 +54,11 @@ class StatsContributionsTest(TestCase): ...@@ -54,11 +54,11 @@ class StatsContributionsTest(TestCase):
self.assertEqual(p.university_pk, self.univ.pk) self.assertEqual(p.university_pk, self.univ.pk)
def test_update_daily_exchange_contributions_info(self): def test_update_daily_exchange_contributions_info(self):
today = get_today_as_datetime()
yesterday = today - timedelta(days=1)
update_daily_exchange_contributions_info() update_daily_exchange_contributions_info()
contributions = DailyExchangeContributionsInfo.objects.filter(date=yesterday) contributions = DailyExchangeContributionsInfo.objects.filter(
date=self.yesterday
)
self.assertEqual(len(contributions), 1) self.assertEqual(len(contributions), 1)
contribution: DailyExchangeContributionsInfo = contributions[0] contribution: DailyExchangeContributionsInfo = contributions[0]
......
Supports Markdown
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