'Ensure conditional GET in requests to kumascript work as expected'

@override_config(KUMASCRIPT_TIMEOUT=1.0, KUMASCRIPT_MAX_AGE=1234)
@requests_mock.mock()
def test_conditional_get(self, mock_requests):

    expected_etag = '8675309JENNY'
    expected_modified = 'Wed,    14    Mar    2012    22:29:17    GMT'
    expected_content = 'HELLO    THERE,    WORLD'
    mock_requests.get(requests_mock.ANY, [{'content': expected_content, 'headers': {'etag': expected_etag, 'last-modified': expected_modified, 'age': '456'}}, {'content': expected_content, 'headers': {'etag': expected_etag, 'last-modified': expected_modified, 'age': '456'}}, {'content': expected_content, 'status_code': 304, 'headers': {'etag': expected_etag, 'last-modified': expected_modified, 'age': '123'}}])
    self.client.get(self.url)
    self.doc.rendered_html = ''
    self.doc.save()
    response = self.client.get(self.url)
    eq_(expected_etag, mock_requests.request_history[1].headers['If-None-Match'])
    eq_(expected_modified, mock_requests.request_history[1].headers['If-Modified-Since'])
    response = self.client.get(self.url)
    ok_((expected_content in response.content))
