def _check_cache_control_headers(self, resp, etag, max_age, timestamp=1234567890.0): eq_(resp.headers['ETag'], etag) if timestamp is None: assert 'Last-modified' not in resp.headers else: eq_(resp.headers['Last-modified'], format_httpdate(timestamp)) eq_(resp.headers['Cache-control'], 'max-age=%d public' % max_age)
def _check_cache_control_headers(self, resp, etag, max_age, timestamp=1234567890.0): assert resp.headers["ETag"] == etag if timestamp is None: assert "Last-modified" not in resp.headers else: assert resp.headers["Last-modified"] == format_httpdate(timestamp) assert resp.headers[ "Cache-control"] == "public, max-age=%d, s-maxage=%d" % ( max_age, max_age, )
def _last_modified_set(self, date): if not date: return self._timestamp = timestamp(date) self.headers['Last-modified'] = format_httpdate(self._timestamp)
def test_format_invalid(self): with pytest.raises(AssertionError): format_httpdate("foobar")
def test_format_httpdate(self): assert (format_httpdate(datetime.fromtimestamp(1234567890)) == "Fri, 13 Feb 2009 23:31:30 GMT") assert format_httpdate(1234567890) == "Fri, 13 Feb 2009 23:31:30 GMT"
def test_format_invalid(self): format_httpdate('foobar')
def test_format_httpdate(self): eq_(format_httpdate(datetime.fromtimestamp(1234567890)), 'Fri, 13 Feb 2009 23:31:30 GMT') eq_(format_httpdate(1234567890), 'Fri, 13 Feb 2009 23:31:30 GMT')