mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 01:21:07 +00:00
Adds basic tests for redis status key deletion
This commit is contained in:
parent
1c9bc936f6
commit
ea85c119b2
2 changed files with 43 additions and 1 deletions
|
@ -49,3 +49,45 @@ class RedisStatusViews(TestCase):
|
|||
self.assertIsInstance(result, TemplateResponse)
|
||||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
def test_redis_status_post_scan_keys(self):
|
||||
"""count keys in redis"""
|
||||
view = views.RedisStatus.as_view()
|
||||
request = self.factory.post("", {"dry_run": True})
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertTrue("outdated_identified" in result.context_data)
|
||||
self.assertFalse("outdated_deleted" in result.context_data)
|
||||
self.assertFalse("cache_deleted" in result.context_data)
|
||||
|
||||
def test_redis_status_post_erase_keys(self):
|
||||
"""count keys in redis"""
|
||||
view = views.RedisStatus.as_view()
|
||||
request = self.factory.post("")
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertFalse("outdated_identified" in result.context_data)
|
||||
self.assertTrue("outdated_deleted" in result.context_data)
|
||||
self.assertFalse("cache_deleted" in result.context_data)
|
||||
|
||||
def test_redis_status_post_erase_cache(self):
|
||||
"""count keys in redis"""
|
||||
view = views.RedisStatus.as_view()
|
||||
request = self.factory.post("", {"erase_cache": True})
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertFalse("outdated_identified" in result.context_data)
|
||||
self.assertFalse("outdated_deleted" in result.context_data)
|
||||
self.assertTrue("cache_deleted" in result.context_data)
|
||||
|
|
|
@ -55,7 +55,7 @@ def view_data():
|
|||
"""Helper function to load basic info for the view"""
|
||||
data = {"errors": [], "prefix": settings.CACHE_KEY_PREFIX}
|
||||
try:
|
||||
data["info"] = r.info
|
||||
data["info"] = r.info()
|
||||
# pylint: disable=broad-except
|
||||
except Exception as err:
|
||||
data["errors"].append(err)
|
||||
|
|
Loading…
Reference in a new issue