Пример #1
0
 def testEquality(self):
     i1 = QgsInterval()
     i2 = QgsInterval()
     self.assertEqual(i1, i2)
     i1 = QgsInterval(5)
     self.assertNotEqual(i1, i2)
     i1.setValid(False)
     i2 = QgsInterval(5)
     self.assertNotEqual(i1, i2)
     i1 = QgsInterval(5)
     self.assertEqual(i1, i2)
     i1.setSeconds(6)
     self.assertNotEqual(i1, i2)
Пример #2
0
    def testIntervalConstructor(self):
        """ Test QgsInterval constructor """

        # invalid interval
        i = QgsInterval()
        self.assertFalse(i.isValid())
        i.setValid(True)
        self.assertTrue(i.isValid())
        i.setValid(False)
        self.assertFalse(i.isValid())
        # setting a duration should make interval valid
        i.setSeconds(5)
        self.assertTrue(i.isValid())

        # constructor with duration
        i = QgsInterval(56)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 56)
Пример #3
0
    def testIntervalConstructor(self):
        """ Test QgsInterval constructor """

        # invalid interval
        i = QgsInterval()
        self.assertFalse(i.isValid())
        i.setValid(True)
        self.assertTrue(i.isValid())
        i.setValid(False)
        self.assertFalse(i.isValid())
        # setting a duration should make interval valid
        i.setSeconds(5)
        self.assertTrue(i.isValid())

        # constructor with duration
        i = QgsInterval(56)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 56)
Пример #4
0
    def testIntervalConstructor(self):
        """ Test QgsInterval constructor """

        # invalid interval
        i = QgsInterval()
        self.assertFalse(i.isValid())
        i.setValid(True)
        self.assertTrue(i.isValid())
        i.setValid(False)
        self.assertFalse(i.isValid())
        # setting a duration should make interval valid
        i.setSeconds(5)
        self.assertTrue(i.isValid())

        # constructor with duration
        i = QgsInterval(56)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 56)

        # constructor with unit type
        i = QgsInterval(56, QgsUnitTypes.TemporalMilliseconds)
        self.assertTrue(i.isValid())
        self.assertEqual(i.seconds(), 0.056)