django.test.skipUnlessDBFeature

Here are the examples of the python api django.test.skipUnlessDBFeature taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

Example 1

Project: django-firebird Source File: tests.py
    @test.skipUnlessDBFeature("supports_microsecond_precision")
    def test_datetimes_save_completely(self):
        dat = datetime.date(2014, 3, 12)
        datetim = datetime.datetime(2014, 3, 12, 21, 22, 23, 240000)
        tim = datetime.time(21, 22, 23, 240000)
        DateTimeModel.objects.create(d=dat, dt=datetim, t=tim)
        obj = DateTimeModel.objects.first()
        self.assertTrue(obj)
        self.assertEqual(obj.d, dat)
        self.assertEqual(obj.dt, datetim)
        self.assertEqual(obj.t, tim)

Example 2

Project: django-firebird Source File: tests.py
    @requires_tz_support
    @test.skipUnlessDBFeature('has_zoneinfo_database')
    @test.override_settings(USE_TZ=True, TIME_ZONE='America/Vancouver')
    def test_lookup_date_with_use_tz(self):
        d = datetime.date(2014, 3, 12)
        # The following is equivalent to UTC 2014-03-12 18:34:23.24000.
        dt1 = datetime.datetime(
            2014, 3, 12, 10, 22, 23, 240000,
            tzinfo=timezone.get_current_timezone()
        )
        # The following is equivalent to UTC 2014-03-13 05:34:23.24000.
        dt2 = datetime.datetime(
            2014, 3, 12, 21, 22, 23, 240000,
            tzinfo=timezone.get_current_timezone()
        )
        t = datetime.time(21, 22, 23, 240000)
        m1 = DateTimeModel.objects.create(d=d, dt=dt1, t=t)
        m2 = DateTimeModel.objects.create(d=d, dt=dt2, t=t)
        # In Vancouver, we expect both results.
        self.assertQuerysetEqual(
            DateTimeModel.objects.filter(dt__date=d),
            [repr(m1), repr(m2)],
            ordered=False
        )
        with self.settings(TIME_ZONE='UTC'):
            # But in UTC, the __date only matches one of them.
            self.assertQuerysetEqual(
                DateTimeModel.objects.filter(dt__date=d),
                [repr(m1)]
            )