Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
fb61db1e
Commit
fb61db1e
authored
Nov 10, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify tests with freezegun.
parent
28dbb843
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
test/test_relative_date.py
test/test_relative_date.py
+9
-10
No files found.
test/test_relative_date.py
View file @
fb61db1e
...
@@ -16,20 +16,19 @@
...
@@ -16,20 +16,19 @@
import
unittest
import
unittest
from
datetime
import
date
,
timedelta
from
datetime
import
date
,
timedelta
from
freezegun
import
freeze_time
from
test.topydo_testcase
import
TopydoTest
from
test.topydo_testcase
import
TopydoTest
from
topydo.lib.RelativeDate
import
relative_date_to_date
from
topydo.lib.RelativeDate
import
relative_date_to_date
@
freeze_time
(
'2015, 11, 06'
)
class
RelativeDateTester
(
TopydoTest
):
class
RelativeDateTester
(
TopydoTest
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
RelativeDateTester
,
self
).
setUp
()
super
(
RelativeDateTester
,
self
).
setUp
()
self
.
today
=
date
.
today
()
self
.
today
=
date
(
2015
,
11
,
6
)
self
.
tomorrow
=
self
.
today
+
timedelta
(
1
)
self
.
tomorrow
=
date
(
2015
,
11
,
7
)
self
.
monday
=
date
(
2015
,
11
,
9
)
self
.
monday
=
self
.
today
if
self
.
monday
.
weekday
()
!=
0
:
self
.
monday
+=
timedelta
(
7
-
self
.
today
.
weekday
()
%
7
)
def
test_zero_days
(
self
):
def
test_zero_days
(
self
):
result
=
relative_date_to_date
(
'0d'
)
result
=
relative_date_to_date
(
'0d'
)
...
@@ -41,7 +40,7 @@ class RelativeDateTester(TopydoTest):
...
@@ -41,7 +40,7 @@ class RelativeDateTester(TopydoTest):
def
test_one_week
(
self
):
def
test_one_week
(
self
):
result
=
relative_date_to_date
(
'1w'
)
result
=
relative_date_to_date
(
'1w'
)
self
.
assertEqual
(
result
,
date
.
today
()
+
timedelta
(
weeks
=
1
))
self
.
assertEqual
(
result
,
date
(
2015
,
11
,
13
))
def
test_one_month
(
self
):
def
test_one_month
(
self
):
test_date
=
date
(
2015
,
1
,
10
)
test_date
=
date
(
2015
,
1
,
10
)
...
@@ -104,7 +103,7 @@ class RelativeDateTester(TopydoTest):
...
@@ -104,7 +103,7 @@ class RelativeDateTester(TopydoTest):
self
.
assertEqual
(
result
,
self
.
today
)
self
.
assertEqual
(
result
,
self
.
today
)
def
test_today3
(
self
):
def
test_today3
(
self
):
result
=
relative_date_to_date
(
'today'
,
date
.
today
()
+
timedelta
(
1
)
)
result
=
relative_date_to_date
(
'today'
,
self
.
tomorrow
)
self
.
assertEqual
(
result
,
self
.
today
)
self
.
assertEqual
(
result
,
self
.
today
)
def
test_tomorrow1
(
self
):
def
test_tomorrow1
(
self
):
...
@@ -133,11 +132,11 @@ class RelativeDateTester(TopydoTest):
...
@@ -133,11 +132,11 @@ class RelativeDateTester(TopydoTest):
def
test_offset1
(
self
):
def
test_offset1
(
self
):
result
=
relative_date_to_date
(
'1d'
,
self
.
tomorrow
)
result
=
relative_date_to_date
(
'1d'
,
self
.
tomorrow
)
self
.
assertEqual
(
result
,
date
.
today
()
+
timedelta
(
2
))
self
.
assertEqual
(
result
,
date
(
2015
,
11
,
8
))
def
test_negative_period1
(
self
):
def
test_negative_period1
(
self
):
result
=
relative_date_to_date
(
'-1d'
)
result
=
relative_date_to_date
(
'-1d'
)
self
.
assertEqual
(
result
,
date
.
today
()
-
timedelta
(
1
))
self
.
assertEqual
(
result
,
date
(
2015
,
11
,
5
))
def
test_negative_period2
(
self
):
def
test_negative_period2
(
self
):
result
=
relative_date_to_date
(
'-0d'
)
result
=
relative_date_to_date
(
'-0d'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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