コード例 #1
0
ファイル: test_filter.py プロジェクト: willgeary/gtfspy
    def test_filter_end_date_not_included(self):
        # the end date should not be included:
        FilterExtract(self.G,
                      self.fname_copy,
                      start_date="2007-01-02",
                      end_date="2010-12-31").create_filtered_copy()

        hash_copy = hashlib.md5(open(self.fname_copy, 'rb').read()).hexdigest()
        self.assertNotEqual(self.hash_orig, hash_copy)
        G_copy = GTFS(self.fname_copy)
        dsut_end = G_copy.get_day_start_ut("2010-12-31")
        dsut_to_trip_I = G_copy.get_tripIs_within_range_by_dsut(
            dsut_end, dsut_end + 24 * 3600)
        self.assertEqual(len(dsut_to_trip_I), 0)

        calendar_copy = G_copy.get_table("calendar")
        max_date_calendar = max([
            datetime.datetime.strptime(el, "%Y-%m-%d")
            for el in calendar_copy["end_date"].values
        ])
        min_date_calendar = max([
            datetime.datetime.strptime(el, "%Y-%m-%d")
            for el in calendar_copy["start_date"].values
        ])
        end_date_not_included = datetime.datetime.strptime(
            "2010-12-31", "%Y-%m-%d")
        start_date_not_included = datetime.datetime.strptime(
            "2007-01-01", "%Y-%m-%d")
        self.assertLess(max_date_calendar,
                        end_date_not_included,
                        msg="the last date should not be included in calendar")
        self.assertLess(start_date_not_included, min_date_calendar)
        os.remove(self.fname_copy)
コード例 #2
0
ファイル: test_filter.py プロジェクト: willgeary/gtfspy
 def test_filter_by_start_and_end_full_range(self):
     # untested tables with filtering: stops, shapes
     # test filtering by start and end time, copy full range
     FilterExtract(self.G,
                   self.fname_copy,
                   start_date=u"2007-01-01",
                   end_date=u"2011-01-01",
                   update_metadata=False).create_filtered_copy()
     G_copy = GTFS(self.fname_copy)
     dsut_end = G_copy.get_day_start_ut("2010-12-31")
     dsut_to_trip_I = G_copy.get_tripIs_within_range_by_dsut(
         dsut_end, dsut_end + 24 * 3600)
     self.assertGreater(len(dsut_to_trip_I), 0)
     os.remove(self.fname_copy)