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
def test_from_delta(self): assert (before_timestamp_from_options({"minutes": 15}) + 60 * 15) == pytest.approx(time.time(), 1)
def test_from_mtime_missing_file(self): with pytest.raises(SeedConfigurationError): before_timestamp_from_options( {"mtime": "/tmp/does-not-exist-at-all,really"})
def test_from_empty(self): assert before_timestamp_from_options({}) == pytest.approx( time.time(), 1)
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)
def test_from_mtime(self): with TempFile() as tmp: os.utime(tmp, (12376512, 12376512)) assert before_timestamp_from_options({"mtime": tmp}) == 12376512
def test_from_empty(self): assert_almost_equal(before_timestamp_from_options({}), time.time(), -1)
def test_from_delta(self): assert_almost_equal( before_timestamp_from_options({'minutes': 15}) + 60 * 15, time.time(), -1)
def test_from_mtime(self): with TempFile() as tmp: os.utime(tmp, (12376512, 12376512)) eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
def test_from_mtime_missing_file(self): before_timestamp_from_options( {'mtime': '/tmp/does-not-exist-at-all,really'})
def test_from_delta(self): assert_almost_equal( before_timestamp_from_options({'minutes': 15}) + 60 * 15, time.time(), -1 )
def test_from_empty(self): assert_almost_equal( before_timestamp_from_options({}), time.time(), -1 )
def test_from_mtime_missing_file(self): before_timestamp_from_options({'mtime': '/tmp/does-not-exist-at-all,really'})
def test_from_mtime(self): with TempFile() as tmp: os.utime(tmp, (12376512, 12376512)) eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
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)