Skip to content

Commit

Permalink
Add tests for bookmarks api disable cache on check
Browse files Browse the repository at this point in the history
  • Loading branch information
Teknicallity committed Feb 26, 2025
1 parent 8c80ffd commit dc476a3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions bookmarks/tests/test_bookmarks_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,33 @@ def test_check_returns_matching_auto_tags(self):

self.assertCountEqual(auto_tags, ["tag1", "tag2"])

def test_check_disable_cache_clears_metadata_cache(self):
self.authenticate()

self.patch_load_website_metadata = patch.object(
website_loader,
"load_website_metadata",
return_value=WebsiteMetadata(
"https://example.com",
"Scraped metadata",
"Scraped description",
"https://example.com/preview.png",
)
).start()
self.patch_cache_clear = patch.object(website_loader.load_website_metadata, "cache_clear").start()

url = reverse("bookmarks:bookmark-check")
check_url = urllib.parse.quote_plus("https://example.com")
response = self.get(
f"{url}?url={check_url}&disable_cache=true", expected_status_code=status.HTTP_200_OK
)

self.patch_cache_clear.assert_called_once()
self.patch_load_website_metadata.assert_called_once()

self.patch_cache_clear.stop()
self.patch_load_website_metadata.stop()

def test_can_only_access_own_bookmarks(self):
self.authenticate()
self.setup_bookmark()
Expand Down

0 comments on commit dc476a3

Please sign in to comment.