예제 #1
0
 def test_extract_works_as_expected_for_given_datetime_string(self):
     result = DateTimeFormatter.extract("2012-12-24 16:17:18",
                                        timezone="Europe/Berlin")
     self.assertEqual(result.year, 2012)
     self.assertEqual(result.month, 12)
     self.assertEqual(result.day, 24)
     self.assertEqual(result.hour, 16)
     self.assertEqual(result.minute, 17)
     self.assertEqual(result.second, 18)
예제 #2
0
 def test_extract_datetime_works_as_expected_for_given_timestamp(self):
     try:
         result = DateTimeFormatter.extract_datetime(
             "2012-12-24T16:17:18-02:00", timezone="Europe/Berlin")
     except PolyaxonDateTimeFormatterException:
         # Python 3.6 does not support this
         return
     self.assertEqual(result.year, 2012)
     self.assertEqual(result.month, 12)
     self.assertEqual(result.day, 24)
     self.assertEqual(result.hour, 16)
     self.assertEqual(result.minute, 17)
     self.assertEqual(result.second, 18)
예제 #3
0
 def test_extract_works_as_expected_for_given_date_string(self):
     result = DateTimeFormatter.extract("2012-12-24",
                                        timezone="Europe/Berlin")
     self.assertEqual(result.year, 2012)
     self.assertEqual(result.month, 12)
     self.assertEqual(result.day, 24)
예제 #4
0
 def test_extract_datetime_rejects_invalid_datetime(self):
     with self.assertRaises(PolyaxonDateTimeFormatterException):
         DateTimeFormatter.extract_datetime("foo", timezone="Europe/Berlin")
예제 #5
0
 def test_extract_datetime_accepts_raises_for_none(self):
     with self.assertRaises(PolyaxonDateTimeFormatterException):
         DateTimeFormatter.extract_datetime(None, timezone="Europe/Berlin")
예제 #6
0
 def test_format_datetime_accepts_raises_for_none(self):
     with self.assertRaises(PolyaxonDateTimeFormatterException):
         DateTimeFormatter.format_datetime(None)
예제 #7
0
 def test_format_datetime_works_as_expected_for_given_datetime(self):
     result = DateTimeFormatter.format_datetime(
         datetime(2012, 12, 24, 16, 17, 18))
     self.assertEqual(result, "2012-12-24 16:17:18")