Esempio n. 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
Esempio n. 2
0
 def test_from_delta(self):
     assert (before_timestamp_from_options({"minutes": 15}) +
             60 * 15) == pytest.approx(time.time(), 1)
Esempio n. 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"})
Esempio n. 4
0
 def test_from_empty(self):
     assert before_timestamp_from_options({}) == pytest.approx(
         time.time(), 1)
Esempio n. 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)
Esempio n. 6
0
 def test_from_mtime(self):
     with TempFile() as tmp:
         os.utime(tmp, (12376512, 12376512))
         assert before_timestamp_from_options({"mtime": tmp}) == 12376512
Esempio n. 7
0
 def test_from_empty(self):
     assert_almost_equal(before_timestamp_from_options({}), time.time(), -1)
Esempio n. 8
0
 def test_from_delta(self):
     assert_almost_equal(
         before_timestamp_from_options({'minutes': 15}) + 60 * 15,
         time.time(), -1)
Esempio n. 9
0
 def test_from_mtime(self):
     with TempFile() as tmp:
         os.utime(tmp, (12376512, 12376512))
         eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
Esempio n. 10
0
 def test_from_mtime_missing_file(self):
     before_timestamp_from_options(
         {'mtime': '/tmp/does-not-exist-at-all,really'})
Esempio n. 11
0
 def test_from_delta(self):
     assert_almost_equal(
         before_timestamp_from_options({'minutes': 15}) + 60 * 15,
         time.time(), -1
     )
Esempio n. 12
0
 def test_from_empty(self):
     assert_almost_equal(
         before_timestamp_from_options({}),
         time.time(), -1
     )
Esempio n. 13
0
 def test_from_mtime_missing_file(self):
     before_timestamp_from_options({'mtime': '/tmp/does-not-exist-at-all,really'})
Esempio n. 14
0
 def test_from_mtime(self):
     with TempFile() as tmp:
         os.utime(tmp, (12376512, 12376512))
         eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
Esempio n. 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)