def test_timestampfield_2(self): f = TimeStampField(null=True) assert None == f.clean(None) pytest.raises(ValidationError, f.clean, 'abc') pytest.raises(ValidationError, f.clean, 'Wed Aug 29 17:12:58 +0000 2012') assert datetime.datetime(1970, 1, 1, 0, 2, 3, tzinfo=utc) == f.clean(123) assert datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc) == f.clean(datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc))
def test_timestampfield_3(self): f = TimeStampField() self.assertEqual(None, f.prepare(None)) self.assertEqual(123, f.prepare(datetime.datetime(1970, 1, 1, 0, 2, 3, tzinfo=utc))) self.assertEqual(123, f.prepare(123)) self.assertEqual(123, f.prepare( datetime.datetime(1970, 1, 1, 10, 2, 3, tzinfo=FixedTimezone.from_hours_minutes(10))))
def test_timestampfield_2(self): f = TimeStampField(null=True) self.assertEqual(None, f.clean(None)) self.assertRaises(ValidationError, f.clean, 'abc') self.assertRaises(ValidationError, f.clean, 'Wed Aug 29 17:12:58 +0000 2012') self.assertEqual(datetime.datetime(1970, 1, 1, 0, 2, 3, tzinfo=utc), f.clean(123)) self.assertEqual(datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc), f.clean(datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc)))
def test_timestampfield_2(self): f = TimeStampField(null=True) assert f.clean(None) is None pytest.raises(ValidationError, f.clean, 'abc') pytest.raises(ValidationError, f.clean, 'Wed Aug 29 17:12:58 +0000 2012') assert datetime.datetime(1970, 1, 1, 0, 2, 3, tzinfo=utc) == f.clean(123) assert datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc) == f.clean( datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc))
def test_timestampfield_2(self): f = TimeStampField(null=True) self.assertEqual(None, f.clean(None)) self.assertRaises(ValidationError, f.clean, 'abc') self.assertRaises(ValidationError, f.clean, 'Wed Aug 29 17:12:58 +0000 2012') self.assertEqual(datetime.datetime(1970, 1, 1, 0, 2, 3, tzinfo=utc), f.clean(123)) self.assertEqual( datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc), f.clean(datetime.datetime(2013, 11, 24, 18, 43, tzinfo=utc)))
def test_timestampfield_3(self): f = TimeStampField() assert f.prepare(None) is None assert 123 == f.prepare(datetime.datetime(1970, 1, 1, 0, 2, 3, tzinfo=utc)) assert 123 == f.prepare(123) assert 123 == f.prepare( datetime.datetime(1970, 1, 1, 10, 2, 3, tzinfo=FixedTimezone.from_hours_minutes(10)))
def test_timestampfield_3(self): f = TimeStampField() self.assertEqual(None, f.prepare(None)) self.assertEqual( 123, f.prepare(datetime.datetime(1970, 1, 1, 0, 2, 3, tzinfo=utc))) self.assertEqual(123, f.prepare(123)) self.assertEqual( 123, f.prepare( datetime.datetime( 1970, 1, 1, 10, 2, 3, tzinfo=FixedTimezone.from_hours_minutes(10))))