Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
c8aee250
Commit
c8aee250
authored
Jun 07, 2020
by
Maxime Emschwiller
Browse files
refacto(backend): refacto test so that they work with refactored computing functions
parent
63164bd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/stats_app/tests/test_nb_connections.py
View file @
c8aee250
...
@@ -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
):
...
...
backend/stats_app/tests/test_nb_contributions.py
View file @
c8aee250
...
@@ -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
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment