Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
afe63cde
Commit
afe63cde
authored
Dec 25, 2023
by
Roang
Browse files
Options
Downloads
Patches
Plain Diff
Fix conference day tests
parent
261dffb4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/tests/conference.py
+36
-35
36 additions, 35 deletions
src/core/tests/conference.py
with
36 additions
and
35 deletions
src/core/tests/conference.py
+
36
−
35
View file @
afe63cde
from
datetime
import
datetime
,
timedelta
from
datetime
import
UTC
,
datetime
,
timedelta
from
unittest.mock
import
patch
import
pytz
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils
.timezone
import
now
from
django.utils
import
timezone
from
..models.conference
import
Conference
from
..models.conference
import
Conference
...
@@ -14,22 +13,22 @@ class ConferenceTests(TestCase):
...
@@ -14,22 +13,22 @@ class ConferenceTests(TestCase):
self
.
conference
.
save
()
self
.
conference
.
save
()
def
test_get_conferenceday
(
self
):
def
test_get_conferenceday
(
self
):
tz
=
pytz
.
timezone
(
'
Europe/Berlin
'
)
self
.
conference
.
start
=
datetime
(
2042
,
12
,
27
,
10
,
00
,
tzinfo
=
UTC
)
self
.
conference
.
start
=
datetime
(
2042
,
12
,
27
,
10
,
00
,
tzinfo
=
tz
)
self
.
conference
.
end
=
datetime
(
2042
,
12
,
30
,
16
,
00
,
tzinfo
=
UTC
)
self
.
conference
.
end
=
datetime
(
2042
,
12
,
30
,
16
,
00
,
tzinfo
=
tz
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
24
,
18
,
00
,
tzinfo
=
UTC
)),
-
2
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
24
,
18
,
00
,
tzinfo
=
tz
)),
-
2
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
26
,
12
,
34
,
tzinfo
=
UTC
)),
0
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
26
,
12
,
34
,
tzinfo
=
tz
)),
0
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
27
,
3
,
45
,
tzinfo
=
UTC
)),
0
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
27
,
3
,
45
,
tzinfo
=
tz
)),
0
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
27
,
12
,
34
,
tzinfo
=
UTC
)),
1
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
27
,
12
,
34
,
tzinfo
=
tz
)),
1
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
30
,
2
,
34
,
tzinfo
=
UTC
)),
3
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
30
,
2
,
34
,
tzinfo
=
tz
)),
3
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
30
,
12
,
34
,
tzinfo
=
UTC
)),
4
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
30
,
12
,
34
,
tzinfo
=
tz
)),
4
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
31
,
5
,
30
,
tzinfo
=
UTC
)),
4
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
31
,
5
,
30
,
tzinfo
=
tz
)),
4
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
31
,
5
,
30
,
tzinfo
=
UTC
)),
4
)
self
.
assertEqual
(
self
.
conference
.
get_conference_day
(
datetime
(
2042
,
12
,
31
,
5
,
30
,
tzinfo
=
tz
)),
4
)
def
test_days_in
(
self
):
def
test_days_in
(
self
):
self
.
conference
.
start
=
now
()
-
timedelta
(
days
=
1
)
with
patch
.
object
(
timezone
,
'
now
'
,
return_value
=
datetime
(
2042
,
12
,
27
,
12
,
34
,
tzinfo
=
UTC
)):
self
.
conference
.
end
=
now
()
+
timedelta
(
days
=
3
)
self
.
conference
.
start
=
timezone
.
now
()
-
timedelta
(
days
=
1
)
self
.
conference
.
end
=
timezone
.
now
()
+
timedelta
(
days
=
3
)
self
.
assertTrue
(
self
.
conference
.
is_running
)
self
.
assertTrue
(
self
.
conference
.
is_running
)
self
.
assertFalse
(
self
.
conference
.
has_ended
)
self
.
assertFalse
(
self
.
conference
.
has_ended
)
self
.
assertEqual
(
5
,
self
.
conference
.
days_count
)
self
.
assertEqual
(
5
,
self
.
conference
.
days_count
)
...
@@ -37,8 +36,9 @@ class ConferenceTests(TestCase):
...
@@ -37,8 +36,9 @@ class ConferenceTests(TestCase):
self
.
assertEqual
(
2
,
self
.
conference
.
current_day
)
self
.
assertEqual
(
2
,
self
.
conference
.
current_day
)
def
test_days_future
(
self
):
def
test_days_future
(
self
):
self
.
conference
.
start
=
now
()
+
timedelta
(
days
=
10
)
with
patch
.
object
(
timezone
,
'
now
'
,
return_value
=
datetime
(
2042
,
12
,
27
,
12
,
34
,
tzinfo
=
UTC
)):
self
.
conference
.
end
=
now
()
+
timedelta
(
days
=
14
)
self
.
conference
.
start
=
timezone
.
now
()
+
timedelta
(
days
=
10
)
self
.
conference
.
end
=
timezone
.
now
()
+
timedelta
(
days
=
14
)
self
.
assertFalse
(
self
.
conference
.
is_running
)
self
.
assertFalse
(
self
.
conference
.
is_running
)
self
.
assertFalse
(
self
.
conference
.
has_ended
)
self
.
assertFalse
(
self
.
conference
.
has_ended
)
self
.
assertEqual
(
5
,
self
.
conference
.
days_count
)
self
.
assertEqual
(
5
,
self
.
conference
.
days_count
)
...
@@ -46,8 +46,9 @@ class ConferenceTests(TestCase):
...
@@ -46,8 +46,9 @@ class ConferenceTests(TestCase):
self
.
assertEqual
(
-
9
,
self
.
conference
.
current_day
)
self
.
assertEqual
(
-
9
,
self
.
conference
.
current_day
)
def
test_days_past
(
self
):
def
test_days_past
(
self
):
self
.
conference
.
start
=
now
()
-
timedelta
(
days
=
5
)
with
patch
.
object
(
timezone
,
'
now
'
,
return_value
=
datetime
(
2042
,
12
,
27
,
12
,
34
,
tzinfo
=
UTC
)):
self
.
conference
.
end
=
now
()
-
timedelta
(
days
=
2
)
self
.
conference
.
start
=
timezone
.
now
()
-
timedelta
(
days
=
5
)
self
.
conference
.
end
=
timezone
.
now
()
-
timedelta
(
days
=
2
)
self
.
assertFalse
(
self
.
conference
.
is_running
)
self
.
assertFalse
(
self
.
conference
.
is_running
)
self
.
assertTrue
(
self
.
conference
.
has_ended
)
self
.
assertTrue
(
self
.
conference
.
has_ended
)
self
.
assertEqual
(
4
,
self
.
conference
.
days_count
)
self
.
assertEqual
(
4
,
self
.
conference
.
days_count
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment