Beispiel #1
0
    def test_stop_station(self):
        dao = Dao()
        f1 = FeedInfo("F1")
        sa = Stop("F1", "SA", "Station A", 45.0000, 0.0000)
        sa1 = Stop("F1", "SA1", "Stop A1", 45.0001, 0.0001)
        sa1.parent_station_id = 'SA'
        sb = Stop("F1", "SB", "Station B", 45.0002, 0.0002)
        sb1 = Stop("F1", "SB1", "Stop B1", 45.0003, 0.0003)
        sb1.parent_station_id = 'SB'
        sb2 = Stop("F1", "SB2", "Stop B2", 45.0002, 0.0003)
        sb2.parent_station_id = 'SB'
        a1 = Agency("F1", "A1", "Agency 1", "url1", "Europe/Paris")
        r1 = Route("F1", "R1", "A1", Route.TYPE_BUS)
        c1 = Calendar("F1", "C1")
        t1 = Trip("F1", "T1", "R1", "C1")
        st1a = StopTime("F1", "T1", "SA1", 0, None, 3600, 0.0)
        st1b = StopTime("F1", "T1", "SB1", 1, 3800, None, 100.0)
        dao.add_all([f1, sa, sa1, sb, sb1, sb2, a1, r1, c1, t1, st1a, st1b])

        stops = list(dao.stops(fltr=(Agency.agency_id == 'A1')))
        self.assertTrue(len(stops) == 2)
        self.assertTrue(sa1 in stops)
        self.assertTrue(sb1 in stops)

        stops = list(dao.stops(fltr=(Stop.parent_station_id == 'SA')))
        self.assertTrue(len(stops) == 1)
        self.assertTrue(sa1 in stops)

        stops = list(dao.stops(fltr=(Stop.parent_station_id == 'SB')))
        self.assertTrue(len(stops) == 2)
        self.assertTrue(sb1 in stops)
        self.assertTrue(sb2 in stops)
Beispiel #2
0
 def test_same_station(self):
     s1a = Stop('F1', 'Sa', 'StopA', 45, 0)
     s1b = Stop('F1', 'Sb', 'StopB', 45, 0.1)
     s1 = Stop('F1', 'S', 'Stop', 45, 0.05, location_type=Stop.TYPE_STATION)
     s1a.parent_station_id = 'S'
     s1b.parent_station_id = 'S'
     self.assertTrue(s1a.in_same_station(s1b))
     self.assertTrue(s1b.in_same_station(s1a))
     self.assertTrue(s1.in_same_station(s1a))
     self.assertTrue(s1a.in_same_station(s1))
     s1c = Stop('F2', 'Sb', 'StopB', 45, 0.1)
     s1c.parent_station_id = 'S'
     self.assertFalse(s1c.in_same_station(s1b))
     self.assertFalse(s1c.in_same_station(s1a))
     self.assertFalse(s1a.in_same_station(s1c))
 def test_same_station(self):
     s1a = Stop('F1', 'Sa', 'StopA', 45, 0)
     s1b = Stop('F1', 'Sb', 'StopB', 45, 0.1)
     s1 = Stop('F1', 'S', 'Stop', 45, 0.05, location_type=Stop.TYPE_STATION)
     s1a.parent_station_id = 'S'
     s1b.parent_station_id = 'S'
     self.assertTrue(s1a.in_same_station(s1b))
     self.assertTrue(s1b.in_same_station(s1a))
     self.assertTrue(s1.in_same_station(s1a))
     self.assertTrue(s1a.in_same_station(s1))
     s1c = Stop('F2', 'Sb', 'StopB', 45, 0.1)
     s1c.parent_station_id = 'S'
     self.assertFalse(s1c.in_same_station(s1b))
     self.assertFalse(s1c.in_same_station(s1a))
     self.assertFalse(s1a.in_same_station(s1c))