Skip to content

Commit

Permalink
Add more free text parsing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbuss committed Dec 26, 2012
1 parent d2157db commit e7d63b2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/tests.py
Expand Up @@ -223,6 +223,12 @@ def test_naive(self):
self.assertFalse(converted.tzinfo is None) self.assertFalse(converted.tzinfo is None)
self.assertEqual(converted.tzinfo, pytz.timezone("US/Pacific")) self.assertEqual(converted.tzinfo, pytz.timezone("US/Pacific"))


def test_sysdate_free(self):
s = "Mon Dec 10 23:31:50 EST 2012"
ts_pst = datetime(2012, 12, 10, 20, 31, 50)
query = "%s to pst" % s
self.assertEqual(ts_pst, wtftz.convert_free(query))

def test_sysdate_tz_doesnt_match(self): def test_sysdate_tz_doesnt_match(self):
# TODO: Make this test pass # TODO: Make this test pass
s = "Mon Dec 10 23:31:50 EST 2012" s = "Mon Dec 10 23:31:50 EST 2012"
Expand Down Expand Up @@ -276,6 +282,14 @@ def test_extraction_no_from(self):
self._test_extraction( self._test_extraction(
query, self.est_ts_str, None, "US/Pacific") query, self.est_ts_str, None, "US/Pacific")


def test_extraction_no_from_keyword(self):
query_template = "{ts} {fromz} to {toz}"
query = query_template.format(ts=self.est_ts_str,
fromz="EST",
toz="US/Pacific")
self._test_extraction(
query, self.est_ts_str, "EST", "US/Pacific")



class TestTimesWithoutDates(TestCase): class TestTimesWithoutDates(TestCase):
def test_simple_bare_times(self): def test_simple_bare_times(self):
Expand Down

0 comments on commit e7d63b2

Please sign in to comment.