'Ensure the last-modified stamp of a document is cached'

def test_last_modified(self):

    rev = revision(is_approved=True, save=True)
    doc = rev.document
    get_url = reverse('wiki.document', args=[doc.slug], locale=settings.WIKI_DEFAULT_LANGUAGE)
    cache_key = doc.last_modified_cache_key
    ok_(cache.get(cache_key))
    response = self.client.get(get_url, follow=False)
    ok_(response.has_header('last-modified'))
    last_mod = response['last-modified']
    response = self.client.get(get_url, follow=False, HTTP_IF_MODIFIED_SINCE=last_mod)
    eq_(304, response.status_code)
    cached_last_mod = cache.get(cache_key)
    eq_(doc.modified.strftime('%s'), cached_last_mod)
    time.sleep(1.0)
    revision(document=doc, content='New    edits', save=True)
    ok_((cache.get(cache_key) != cached_last_mod))
    response = self.client.get(get_url, follow=False, HTTP_IF_MODIFIED_SINCE=last_mod)
    eq_(200, response.status_code)
    ok_((last_mod != response['last-modified']))
    ok_((cached_last_mod != cache.get(cache_key)))
