Example #1
0
    def expire_timestamp(self, tile=None):
        """
        Return the timestamp until which a tile should be accepted as up-to-date,
        or ``None`` if the tiles should not expire.

        :note: Returns _expire_timestamp by default.
        """
        if self._refresh_before:
            from mapproxy.seed.config import before_timestamp_from_options
            return before_timestamp_from_options(self._refresh_before)
        return self._expire_timestamp
Example #2
0
 def test_from_delta(self):
     assert (before_timestamp_from_options({"minutes": 15}) +
             60 * 15) == pytest.approx(time.time(), 1)
Example #3
0
 def test_from_mtime_missing_file(self):
     with pytest.raises(SeedConfigurationError):
         before_timestamp_from_options(
             {"mtime": "/tmp/does-not-exist-at-all,really"})
Example #4
0
 def test_from_empty(self):
     assert before_timestamp_from_options({}) == pytest.approx(
         time.time(), 1)
Example #5
0
 def test_from_time(self):
     ts = before_timestamp_from_options({"time": "2010-12-01T20:12:00"})
     # we don't know the timezone this test will run
     assert (1291230720.0 - 14 * 3600) < ts < (1291230720.0 + 14 * 3600)
Example #6
0
 def test_from_mtime(self):
     with TempFile() as tmp:
         os.utime(tmp, (12376512, 12376512))
         assert before_timestamp_from_options({"mtime": tmp}) == 12376512
Example #7
0
 def test_from_empty(self):
     assert_almost_equal(before_timestamp_from_options({}), time.time(), -1)
Example #8
0
 def test_from_delta(self):
     assert_almost_equal(
         before_timestamp_from_options({'minutes': 15}) + 60 * 15,
         time.time(), -1)
Example #9
0
 def test_from_mtime(self):
     with TempFile() as tmp:
         os.utime(tmp, (12376512, 12376512))
         eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
Example #10
0
 def test_from_mtime_missing_file(self):
     before_timestamp_from_options(
         {'mtime': '/tmp/does-not-exist-at-all,really'})
Example #11
0
 def test_from_delta(self):
     assert_almost_equal(
         before_timestamp_from_options({'minutes': 15}) + 60 * 15,
         time.time(), -1
     )
Example #12
0
 def test_from_empty(self):
     assert_almost_equal(
         before_timestamp_from_options({}),
         time.time(), -1
     )
Example #13
0
 def test_from_mtime_missing_file(self):
     before_timestamp_from_options({'mtime': '/tmp/does-not-exist-at-all,really'})
Example #14
0
 def test_from_mtime(self):
     with TempFile() as tmp:
         os.utime(tmp, (12376512, 12376512))
         eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
Example #15
0
 def test_from_time(self):
     ts = before_timestamp_from_options({'time': '2010-12-01T20:12:00'})
     # we don't know the timezone this test will run
     assert (1291230720.0 - 14 * 3600) < ts < (1291230720.0 + 14 * 3600)