Skip to content

Commit

Permalink
tests: add tests for general/week option
Browse files Browse the repository at this point in the history
Signed-off-by: Sandro Bonazzola <[email protected]>
  • Loading branch information
sandrobonazzola committed Feb 8, 2023
1 parent 6ce5b03 commit d74d90c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ def test_Date_period():
assert str(since) == "2014-01-01"
assert str(until) == "2015-01-01"
assert period == "the last year"
# This week in Israel
for argument in ["", "week", "this week"]:
Config(config="[general]\nweek = 6")
since, until, period = Date.period(argument)
assert str(since) == "2015-09-27"
assert str(until) == "2015-10-04"
assert period == "the week 39"
# Last week in Israel
for argument in ["last", "last week"]:
Config(config="[general]\nweek = 6")
since, until, period = Date.period(argument)
assert str(since) == "2015-09-20"
assert str(until) == "2015-09-27"
assert period == "the week 38"
# Adding and subtracting days
assert str(Date('2018-11-29') + 1) == '2018-11-30'
assert str(Date('2018-11-29') + 2) == '2018-12-01'
Expand Down Expand Up @@ -267,7 +281,7 @@ def test_get_token_plain_different_name(self):
token = str(uuid4())
config = {"mytoken": token}
self.assertIsNone(get_token(config))
self.assertEqual(get_token(config, token_key="mytoken"), token)
self.assertEqual(get_token(config, token_key="mytoken"), token) # nosec

def test_get_token_file(self):
""" Test getting a token from a file """
Expand All @@ -278,7 +292,7 @@ def test_get_token_file(self):

def test_get_token_file_empty(self):
""" Test getting a token from a file with just whitespace. """
token_in_file = " "
token_in_file = " " # nosec
with self.get_token_as_file(token_in_file) as filename:
config = {"token_file": filename}
self.assertIsNone(get_token(config))
Expand All @@ -296,7 +310,7 @@ def test_get_token_file_different_name(self):
token_in_file = str(uuid4())
with self.get_token_as_file(token_in_file) as filename:
config = {"mytoken_file": filename}
self.assertEqual(
self.assertEqual( # nosec
get_token(
config,
token_file_key="mytoken_file"),
Expand Down

0 comments on commit d74d90c

Please sign in to comment.