Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #614 from EverythingMe/fix/caching
Fix: don't cache /results API endpoint
- Loading branch information
Showing
3 changed files
with
54 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from tests import BaseTestCase | ||
from tests.factories import query_result_factory, query_factory | ||
from tests.handlers import authenticated_user, json_request | ||
|
||
from redash.wsgi import app | ||
|
||
|
||
class TestQueryResultsCacheHeaders(BaseTestCase): | ||
def test_uses_cache_headers_for_specific_result(self): | ||
query_result = query_result_factory.create() | ||
query = query_factory.create(latest_query_data=query_result) | ||
with app.test_client() as c, authenticated_user(c): | ||
rv = json_request(c.get, '/api/queries/{}/results/{}.json'.format(query.id, query_result.id)) | ||
self.assertIn('Cache-Control', rv.headers) | ||
|
||
def test_doesnt_use_cache_headers_for_non_specific_result(self): | ||
query_result = query_result_factory.create() | ||
query = query_factory.create(latest_query_data=query_result) | ||
with app.test_client() as c, authenticated_user(c): | ||
rv = json_request(c.get, '/api/queries/{}/results.json'.format(query.id)) | ||
self.assertNotIn('Cache-Control', rv.headers) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters