def test_none(self):
        obj = TimestampDescriptorExample()
        obj.timestamp = None
        obj.save()

        obj2 = TimestampDescriptorExample.objects.get(id=obj.id)

        self.assertEqual(obj.timestampSeconds, None)
        self.assertEqual(obj2.timestampSeconds, None)
        self.assertEqual(obj.timestampMicroseconds, 0)
        self.assertEqual(obj2.timestampMicroseconds, 0)
Пример #2
0
    def test_none(self):
        obj = TimestampDescriptorExample()
        obj.timestamp = None
        obj.save()

        obj2 = TimestampDescriptorExample.objects.get(id=obj.id)

        self.assertEqual(obj.timestampSeconds, None)
        self.assertEqual(obj2.timestampSeconds, None)
        self.assertEqual(obj.timestampMicroseconds, 0)
        self.assertEqual(obj2.timestampMicroseconds, 0)
    def test_standard(self):
        ts = datetime.datetime(2012, 5, 22, 7, 37, 16, 689212, tzinfo=pytz.utc)
        obj = TimestampDescriptorExample()
        obj.timestamp = ts
        obj.save()

        obj2 = TimestampDescriptorExample.objects.get(id=obj.id)

        self.assertEqual(obj.timestampSeconds, obj2.timestampSeconds)
        self.assertEqual(obj.timestampSeconds.second, 16)
        self.assertEqual(obj2.timestampSeconds.second, 16)
        self.assertEqual(obj.timestampMicroseconds, 689212)
        self.assertEqual(obj2.timestampMicroseconds, 689212)
Пример #4
0
    def test_standard(self):
        ts = datetime.datetime(2012, 5, 22, 7, 37, 16, 689212)
        obj = TimestampDescriptorExample()
        obj.timestamp = ts
        obj.save()

        obj2 = TimestampDescriptorExample.objects.get(id=obj.id)

        self.assertEqual(obj.timestampSeconds, obj2.timestampSeconds)
        self.assertEqual(obj.timestampSeconds.second, 16)
        self.assertEqual(obj2.timestampSeconds.second, 16)
        self.assertEqual(obj.timestampMicroseconds, 689212)
        self.assertEqual(obj2.timestampMicroseconds, 689212)