Пример #1
0
 def testSettersDurationUnitChange(self):
     i = QgsInterval()
     self.assertEqual(i.originalDuration(), 0.0)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalUnknownUnit)
     i.setYears(1)
     self.assertEqual(i.originalDuration(), 1.0)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalYears)
     i.setMonths(3)
     self.assertEqual(i.originalDuration(), 3.0)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalMonths)
     i.setWeeks(1)
     self.assertEqual(i.originalDuration(), 1.0)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalWeeks)
     i.setDays(4)
     self.assertEqual(i.originalDuration(), 4.0)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalDays)
     i.setHours(22.3)
     self.assertEqual(i.originalDuration(), 22.3)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalHours)
     i.setMinutes(11)
     self.assertEqual(i.originalDuration(), 11.0)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalMinutes)
     i.setSeconds(100)
     self.assertEqual(i.originalDuration(), 100.0)
     self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalSeconds)
Пример #2
0
    def testGettersDurationUnitChange(self):
        i = QgsInterval()
        self.assertEqual(i.originalDuration(), 0.0)
        self.assertEqual(i.originalUnit(), QgsUnitTypes.TemporalUnknownUnit)
        i.setYears(1)
        self.assertEqual(i.years(), 1.0)
        i.setMonths(3)
        self.assertEqual(i.months(), 3.0)
        i.setWeeks(1)
        self.assertEqual(i.weeks(), 1.0)
        i.setDays(4)
        self.assertEqual(i.days(), 4.0)
        i.setHours(22.3)
        self.assertEqual(i.hours(), 22.3)
        i.setMinutes(11)
        self.assertEqual(i.minutes(), 11.0)
        i.setSeconds(100)
        self.assertEqual(i.seconds(), 100.0)

        i = QgsInterval(0, 0, 0, 0, 0, 1, 30)
        self.assertEqual(i.minutes(), 1.5)
        i.setDays(45)
        self.assertEqual(i.months(), 1.5)
Пример #3
0
    def testSettersGetters(self):
        # setters and getters
        i = QgsInterval()
        i.setSeconds(60)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 60.0)

        i = QgsInterval()
        i.setMinutes(10)
        self.assertTrue(i.isValid())
        self.assertEqual(i.minutes(), 10.0)

        i = QgsInterval()
        i.setHours(5)
        self.assertTrue(i.isValid())
        self.assertEqual(i.hours(), 5.0)

        i = QgsInterval()
        i.setDays(70)
        self.assertTrue(i.isValid())
        self.assertEqual(i.days(), 70.0)

        i = QgsInterval()
        i.setWeeks(9)
        self.assertTrue(i.isValid())
        self.assertEqual(i.weeks(), 9.0)

        i = QgsInterval()
        i.setMonths(4)
        self.assertTrue(i.isValid())
        self.assertEqual(i.months(), 4.0)

        i = QgsInterval()
        i.setYears(8)
        self.assertTrue(i.isValid())
        self.assertEqual(i.years(), 8.0)
Пример #4
0
    def testSettersGetters(self):
        # setters and getters
        i = QgsInterval()
        i.setSeconds(60)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 60.0)

        i = QgsInterval()
        i.setMinutes(10)
        self.assertTrue(i.isValid())
        self.assertEqual(i.minutes(), 10.0)

        i = QgsInterval()
        i.setHours(5)
        self.assertTrue(i.isValid())
        self.assertEqual(i.hours(), 5.0)

        i = QgsInterval()
        i.setDays(70)
        self.assertTrue(i.isValid())
        self.assertEqual(i.days(), 70.0)

        i = QgsInterval()
        i.setWeeks(9)
        self.assertTrue(i.isValid())
        self.assertEqual(i.weeks(), 9.0)

        i = QgsInterval()
        i.setMonths(4)
        self.assertTrue(i.isValid())
        self.assertEqual(i.months(), 4.0)

        i = QgsInterval()
        i.setYears(8)
        self.assertTrue(i.isValid())
        self.assertEqual(i.years(), 8.0)