from .base_config_test import BaseConfigTest, fmod from .memento_fixture import * from warcio.timeutils import timestamp_to_http_date # ============================================================================ class TestMemento(MementoMixin, BaseConfigTest): @classmethod def setup_class(cls): super(TestMemento, cls).setup_class('config_test.yaml') def _assert_memento(self, resp, url, ts, fmod, dt=''): dt = dt or timestamp_to_http_date(ts) links = self.get_links(resp) assert MEMENTO_DATETIME in resp.headers assert resp.headers[MEMENTO_DATETIME] == dt # memento link memento_link = self.make_memento_link(url, ts, dt, fmod) assert memento_link in links # content location assert '/pywb/{1}{0}/{2}'.format(fmod, ts, url) in resp.headers['Content-Location'] # content location part of memento link assert resp.headers['Content-Location'] in memento_link # timegate link assert self.make_timegate_link(url, fmod) in links # timemap link assert self.make_timemap_link(url) in links # original assert self.make_original_link(url) in links # Memento Pattern 2.2 (no redirect, 200 negotiation) def test_memento_top_frame(self): resp = self.testapp.get('/pywb/20140127171238/http://www.iana.org/') # Memento Headers # no vary header assert VARY not in resp.headers assert MEMENTO_DATETIME in resp.headers # memento link dt = 'Mon, 27 Jan 2014 17:12:38 GMT' url = 'http://www.iana.org/' links = self.get_links(resp) assert self.make_memento_link(url, '20140127171238', dt, 'mp_') in links #timegate link assert self.make_timegate_link(url, 'mp_') in links # Body assert '