-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make relative parser less greedy, rename test dir
- Loading branch information
Showing
10 changed files
with
627 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import unittest | ||
from unittest.mock import MagicMock | ||
|
||
from datetime import datetime, timedelta | ||
from dateutil.tz import gettz | ||
|
||
import Bot.lib.input_parser as p | ||
|
||
|
||
|
||
class AbsParseTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.utcnow = datetime(year=2021, month=1, day=1) | ||
|
||
|
||
def test_timezone_convert(self): | ||
# timezone in winter is 1h difference | ||
cmp_at = datetime(year=2021, month=1, day=1, hour=0) | ||
at, _ = p.parse('2021-1-1 01:00', self.utcnow, 'Europe/Berlin') | ||
|
||
self.assertEqual(at, cmp_at) | ||
|
||
|
||
def test_summer_time(self): | ||
cmp_at = datetime(year=2021, month=3, day=28, hour=0, minute=59) | ||
at, _ = p.parse('2021-03-28 01:59', self.utcnow, 'Europe/Berlin') | ||
self.assertEqual(at, cmp_at) | ||
|
||
cmp_at = datetime(year=2021, month=3, day=28, hour=1) | ||
at, _ = p.parse('2021-03-28 03:00', self.utcnow, 'Europe/Berlin') | ||
self.assertEqual(at, cmp_at) | ||
|
||
|
||
def test_no_american_format(self): | ||
cmp_at = datetime(year=2021, month=2, day=3) | ||
at, _ = p.parse('3.2.2021', self.utcnow) | ||
|
||
self.assertEqual(at, cmp_at) | ||
|
||
|
||
|
||
import unittest | ||
from unittest.mock import MagicMock | ||
|
||
from datetime import datetime, timedelta | ||
from dateutil.tz import gettz | ||
|
||
import Bot.lib.input_parser as p | ||
|
||
|
||
|
||
class AbsParseTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.utcnow = datetime(year=2021, month=1, day=1) | ||
|
||
|
||
def test_timezone_convert(self): | ||
# timezone in winter is 1h difference | ||
cmp_at = datetime(year=2021, month=1, day=1, hour=0) | ||
at, _ = p.parse('2021-1-1 01:00', self.utcnow, 'Europe/Berlin') | ||
|
||
self.assertEqual(at, cmp_at) | ||
|
||
|
||
def test_summer_time(self): | ||
cmp_at = datetime(year=2021, month=3, day=28, hour=0, minute=59) | ||
at, _ = p.parse('2021-03-28 01:59', self.utcnow, 'Europe/Berlin') | ||
self.assertEqual(at, cmp_at) | ||
|
||
cmp_at = datetime(year=2021, month=3, day=28, hour=1) | ||
at, _ = p.parse('2021-03-28 03:00', self.utcnow, 'Europe/Berlin') | ||
self.assertEqual(at, cmp_at) | ||
|
||
|
||
def test_no_american_format(self): | ||
cmp_at = datetime(year=2021, month=2, day=3) | ||
at, _ = p.parse('3.2.2021', self.utcnow) | ||
|
||
self.assertEqual(at, cmp_at) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import unittest | ||
from unittest.mock import MagicMock | ||
|
||
from datetime import datetime, timedelta | ||
|
||
import Bot.lib.input_parser as p | ||
|
||
|
||
|
||
class AmbigParseTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.utcnow = datetime(year=2021, month=1, day=1) | ||
|
||
|
||
def test_m_minute(self): | ||
""" keyword m must be interpreted as minutes | ||
a warning is not shown | ||
""" | ||
at, error = p.parse('1m', self.utcnow) | ||
|
||
self.assertEqual(at, self.utcnow+timedelta(minutes=1)) | ||
import unittest | ||
from unittest.mock import MagicMock | ||
|
||
from datetime import datetime, timedelta | ||
|
||
import Bot.lib.input_parser as p | ||
|
||
|
||
|
||
class AmbigParseTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.utcnow = datetime(year=2021, month=1, day=1) | ||
|
||
|
||
def test_m_minute(self): | ||
""" keyword m must be interpreted as minutes | ||
a warning is not shown | ||
""" | ||
at, error = p.parse('1m', self.utcnow) | ||
|
||
self.assertEqual(at, self.utcnow+timedelta(minutes=1)) | ||
self.assertEqual(error, '') # m does not trigger warning anymore |
Oops, something went wrong.