コード例 #1
0
 def test_bc_distance(self):
     end = bcdate_util.BCDate(10)
     start = bcdate_util.BCDate(-10)
     assert (bcdate_util.BCDate.dist(end, start) == 19)
     end = bcdate_util.BCDate(-10)
     start = bcdate_util.BCDate(-30)
     assert (bcdate_util.BCDate.dist(end, start) == 20)
コード例 #2
0
 def test_date_with_bc_is_detected_as_such(self):
     dtstr = "0020 BC"
     assert (
         time_util.get_format_of_timeval(dtstr) == bcdate_util.BC_FORMAT)
     assert (time_util.timeval_to_datetime(
         dtstr, bcdate_util.BC_FORMAT) == bcdate_util.BCDate(-20, 1, 1))
     dtstr = "0020 AD"
     assert (
         time_util.get_format_of_timeval(dtstr) == bcdate_util.BC_FORMAT)
     assert (time_util.timeval_to_datetime(
         dtstr, bcdate_util.BC_FORMAT) == bcdate_util.BCDate(20, 1, 1))
     assert (time_util.DateTypes.determine_type(dtstr) ==
             time_util.DateTypes.DatesAsStringsArchaelogical)
コード例 #3
0
    def test_archaeological_range_queries(self):
        try:
            layer = self.getArchaelogicalLayer()
            self.ctrl.setArchaeology(1)
            assert (time_util.is_archaelogical())
            settings = ls.LayerSettings()
            settings.layer = layer
            settings.startTimeAttribute = "year"
            settings.endTimeAttribute = "endyear"
            iface = Mock()
            timeLayer = timevectorlayer.TimeVectorLayer(settings, iface)
            self.tlm.registerTimeLayer(timeLayer)
            self.assertEquals(len(self.tlm.getActiveVectors()), 1)
            self.assertEquals(timeLayer.getDateType(),
                              time_util.DateTypes.DatesAsStringsArchaelogical)
            self.assertEquals(timeLayer.getTimeFormat(), bcdate_util.BC_FORMAT)
            self.tlm.setTimeFrameType("years")
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(-452))
            self.assertEquals(layer.featureCount(), 0)
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(-400))
            self.assertEquals(layer.featureCount(), 1)
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(-352))
            self.assertEquals(layer.featureCount(), 2)
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(-9))
            self.assertEquals(layer.featureCount(), 2)
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(180))
            self.assertEquals(layer.featureCount(), 0)
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(1))
            self.assertEquals(layer.featureCount(), 2)
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(333))
            self.assertEquals(layer.featureCount(), 1)
            self.tlm.setCurrentTimePosition(bcdate_util.BCDate(-450))
            self.tlm.setTimeFrameSize(500)
            self.assertEquals(layer.featureCount(), 4)
            self.tlm.setTimeFrameSize(1000)
            self.assertEquals(layer.featureCount(), 5)

            # expected_datetime = time_util.epoch_to_datetime(self.get_start_time())
            #self.assertEquals(self.tlm.getCurrentTimePosition(),expected_datetime)
            #self.assertEquals(layer.featureCount(),1)
            #self.tlm.stepForward()
            #self.tlm.setTimeFrameSize(2)
            self.tlm.clearTimeLayerList()
            self.ctrl.setArchaeology(0)
        except Exception, e:
            self.tlm.clearTimeLayerList()
            self.ctrl.setArchaeology(0)
            raise e
コード例 #4
0
 def test_ad(self):
     val = "0001 AD"
     dt = time_util.timeval_to_datetime(val, None)
     assert (dt == bcdate_util.BCDate(1))
コード例 #5
0
 def test_max_date(self):
     self.assertEqual(bcdate_util.get_max_dt(), bcdate_util.BCDate(9999))