예제 #1
0
 def test_snapping_4a(self):
     layer_name = 'snap_test_4a'
     tests = (('2000-01-01', '2000-01-01'),
              ('2000-01-20', '2000-01-01'),
              ('2000-06-10', '2000-06-01'),
              ('2000-07-01', 'black'),
              ('2000-07-02', 'black'),
              ('2000-07-03', '2000-07-03'),
              ('2000-07-20', '2000-07-03'),
              ('2000-08-01', '2000-08-01'),
              ('2000-08-10', '2000-08-01'),
              ('2000-12-31', '2000-12-01'),
              ('1999-12-31', 'black'),
              ('2001-01-01', 'black'))
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
     if DEBUG:
         print '\nTesting Irregular Multi-day date snapping (e.g. irregular periods intermixed with consistent periods'
         print 'Time Period 4a: 2000-01-01/2000-06-01/P1M,2000-07-03/2000-07-03/P1M,2000-08-01/2000-12-01/P1M'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 4a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #2
0
 def test_snapping_4a(self):
     layer_name = 'snap_test_4a'
     tests = (('2000-01-01', '2000-01-01'),
              ('2000-01-20', '2000-01-01'),
              ('2000-06-10', '2000-06-01'),
              ('2000-07-01', 'black'),
              ('2000-07-02', 'black'),
              ('2000-07-03', '2000-07-03'),
              ('2000-07-20', '2000-07-03'),
              ('2000-08-01', '2000-08-01'),
              ('2000-08-10', '2000-08-01'),
              ('2000-12-31', '2000-12-01'),
              ('1999-12-31', 'black'),
              ('2001-01-01', 'black'))
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
     if DEBUG:
         print '\nTesting Irregular Multi-day date snapping (e.g. irregular periods intermixed with consistent periods'
         print 'Time Period 4a: 2000-01-01/2000-06-01/P1M,2000-07-03/2000-07-03/P1M,2000-08-01/2000-12-01/P1M'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 4a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #3
0
 def test_snapping_5a(self):
     layer_name = 'snap_test_5a'
     expected_date = datetime.date(2002, 12, 01)
     while (expected_date.year < 2012):
         end_date = expected_date.replace(year=expected_date.year + 1) + datetime.timedelta(days=-1)
         req_date = expected_date
         while (req_date < end_date):
             req_url = self.snap_test_url_template.format(layer_name, req_date)
             response_date = test_snap_request(self.tile_hashes, req_url)
             error = 'Snapping test 5a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(req_date.isoformat(), expected_date.isoformat(), response_date, req_url)
             self.assertEqual(expected_date.isoformat(), response_date, error)
             req_date += datetime.timedelta(days=+1)
         expected_date = expected_date.replace(expected_date.year + 1)
예제 #4
0
 def test_snapping_5a(self):
     layer_name = 'snap_test_5a'
     expected_date = datetime.date(2002, 12, 01)
     while (expected_date.year < 2012):
         end_date = expected_date.replace(year=expected_date.year + 1) + datetime.timedelta(days=-1)
         req_date = expected_date
         while (req_date < end_date):
             req_url = self.snap_test_url_template.format(layer_name, req_date)
             response_date = test_snap_request(self.tile_hashes, req_url)
             error = 'Snapping test 5a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(req_date.isoformat(), expected_date.isoformat(), response_date, req_url)
             self.assertEqual(expected_date.isoformat(), response_date, error)
             req_date += datetime.timedelta(days=+1)
         expected_date = expected_date.replace(expected_date.year + 1)
예제 #5
0
 def test_snapping_2a(self):
     layer_name = 'snap_test_2a'
     tests = (('2015-01-01', '2015-01-01'),
              ('2015-01-11', 'black'),
              ('2015-01-12', '2015-01-12'),
              ('2015-02-01', 'black'))
     if DEBUG:
         print '\nTesting Date Snapping: Irregular Daily date (PID with gaps)'
         print 'Time Period 2a: 2015-01-01/2015-01-10/P1D, 2015-01-12/2015-01-31/P1D'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 2a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #6
0
 def test_snapping_2a(self):
     layer_name = 'snap_test_2a'
     tests = (('2015-01-01', '2015-01-01'),
              ('2015-01-11', 'black'),
              ('2015-01-12', '2015-01-12'),
              ('2015-02-01', 'black'))
     if DEBUG:
         print '\nTesting Date Snapping: Irregular Daily date (PID with gaps)'
         print 'Time Period 2a: 2015-01-01/2015-01-10/P1D, 2015-01-12/2015-01-31/P1D'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 2a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #7
0
 def test_year_boundary_snapping(self):
     layer_name = 'snap_test_year_boundary'
     tests = (('2000-09-03', '2000-09-03'),
              ('2001-01-24', '2000-09-03'),
              ('2000-01-25', 'black'))
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
     if DEBUG:
         print '\nTesting Date Snapping: Periods stretching across a year boundary'
         print 'Time Period year boundary: 2000-09-03/2000-09-03/P144D'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test for periods stretching across a year boundary requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #8
0
 def test_year_boundary_snapping(self):
     layer_name = 'snap_test_year_boundary'
     tests = (('2000-09-03', '2000-09-03'),
              ('2001-01-24', '2000-09-03'),
              ('2000-01-25', 'black'))
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
     if DEBUG:
         print '\nTesting Date Snapping: Periods stretching across a year boundary'
         print 'Time Period year boundary: 2000-09-03/2000-09-03/P144D'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test for periods stretching across a year boundary requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #9
0
 def test_snapping_3b(self):
     layer_name = 'snap_test_3b'
     tests = (('2015-01-01', '2015-01-01'),
              ('2015-01-20', '2015-01-01'),
              ('2015-12-31', '2015-10-01'),
              ('2016-01-01', '2016-01-01'),
              ('2016-01-20', '2016-01-01'),
              ('2016-04-01', 'black'),
              ('2014-12-31', 'black'))
     if DEBUG:
         print '\nTesting Date Snapping: Regular Multi-day date snapping (e.g. consistent 8-day, monthly, yearly cadence)'
         print 'Time Period 3b: 2015-01-01/2016-01-01/P3M'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 3b requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #10
0
 def test_snapping_3b(self):
     layer_name = 'snap_test_3b'
     tests = (('2015-01-01', '2015-01-01'),
              ('2015-01-20', '2015-01-01'),
              ('2015-12-31', '2015-10-01'),
              ('2016-01-01', '2016-01-01'),
              ('2016-01-20', '2016-01-01'),
              ('2016-04-01', 'black'),
              ('2014-12-31', 'black'))
     if DEBUG:
         print '\nTesting Date Snapping: Regular Multi-day date snapping (e.g. consistent 8-day, monthly, yearly cadence)'
         print 'Time Period 3b: 2015-01-01/2016-01-01/P3M'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 3b requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #11
0
    def test_snapping_1a(self):
        # This is the layer name that will be used in the WMTS request
        layer_name = 'snap_test_1a'

        # Tests are tuples with order of (request date, expected date)
        # Note that date/hash pairs must exist in self.tile_hashes dict
        tests = (('2015-01-01', '2015-01-01'),
                 ('2015-01-02', '2015-01-02'),
                 ('2016-02-29', '2016-02-29'),
                 ('2017-01-01', 'black'))
        if DEBUG:
            print '\nTesting Date Snapping: Regular Daily date (P1D)'
            print 'Time Period 1a: 2015-01-01/2016-12-31/P1D'
        for request_date, expected_date in tests:
            req_url = self.snap_test_url_template.format(layer_name, request_date)
            if DEBUG:
                print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
                print 'URL: ' + req_url
            response_date = test_snap_request(self.tile_hashes, req_url)
            error = 'Snapping test 1a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
            self.assertEqual(expected_date, response_date, error)
예제 #12
0
    def test_snapping_1a(self):
        # This is the layer name that will be used in the WMTS request
        layer_name = 'snap_test_1a'

        # Tests are tuples with order of (request date, expected date)
        # Note that date/hash pairs must exist in self.tile_hashes dict
        tests = (('2015-01-01', '2015-01-01'),
                 ('2015-01-02', '2015-01-02'),
                 ('2016-02-29', '2016-02-29'),
                 ('2017-01-01', 'black'))
        if DEBUG:
            print '\nTesting Date Snapping: Regular Daily date (P1D)'
            print 'Time Period 1a: 2015-01-01/2016-12-31/P1D'
        for request_date, expected_date in tests:
            req_url = self.snap_test_url_template.format(layer_name, request_date)
            if DEBUG:
                print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
                print 'URL: ' + req_url
            response_date = test_snap_request(self.tile_hashes, req_url)
            error = 'Snapping test 1a requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
            self.assertEqual(expected_date, response_date, error)
예제 #13
0
 def test_snapping_4b(self):
     layer_name = 'snap_test_4b'
     tests = (('2001-01-01', '2001-01-01'),
              ('2001-01-05', '2001-01-01'),
              ('2001-05-14', '2001-05-09'),
              ('2002-01-01', '2002-01-01'),
              ('2000-12-31', 'black'),
              ('2003-01-01', '2002-12-27'),
              ('2003-01-04', 'black'))
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
     if DEBUG:
         print '\nTesting Irregular Multi-day date snapping (e.g. irregular periods intermixed with consistent periods'
         print 'Time Period 4b: 2001-01-01/2001-12-27/P8D, 2002-01-01/2002-12-27/P8D'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 4b requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)
예제 #14
0
 def test_snapping_4b(self):
     layer_name = 'snap_test_4b'
     tests = (('2001-01-01', '2001-01-01'),
              ('2001-01-05', '2001-01-01'),
              ('2001-05-14', '2001-05-09'),
              ('2002-01-01', '2002-01-01'),
              ('2000-12-31', 'black'),
              ('2003-01-01', '2002-12-27'),
              ('2003-01-04', 'black'))
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
     if DEBUG:
         print '\nTesting Irregular Multi-day date snapping (e.g. irregular periods intermixed with consistent periods'
         print 'Time Period 4b: 2001-01-01/2001-12-27/P8D, 2002-01-01/2002-12-27/P8D'
     for request_date, expected_date in tests:
         req_url = self.snap_test_url_template.format(layer_name, request_date)
         if DEBUG:
             print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)
             print 'URL: ' + req_url
         response_date = test_snap_request(self.tile_hashes, req_url)
         error = 'Snapping test 4b requested date {0}, expected {1}, but got {2}. \nURL: {3}'.format(request_date, expected_date, response_date, req_url)
         self.assertEqual(expected_date, response_date, error)