def archived(request): query_string = request.GET.get('q') query_set = queries.query_archived_bookmarks(request.user, query_string) tags = queries.query_archived_bookmark_tags(request.user, query_string) base_url = reverse('bookmarks:archived') context = get_bookmark_view_context(request, query_set, tags, base_url) return render(request, 'bookmarks/archive.html', context)
def test_query_archived_bookmarks_should_not_return_unarchived_bookmarks( self): bookmark1 = self.setup_bookmark(is_archived=True) bookmark2 = self.setup_bookmark(is_archived=True) self.setup_bookmark() self.setup_bookmark() self.setup_bookmark() query = queries.query_archived_bookmarks( self.get_or_create_test_user(), '') self.assertCountEqual([bookmark1, bookmark2], list(query))
def test_query_archived_bookmarks_should_not_return_unarchived_bookmarks( self): bookmark1 = self.setup_bookmark(is_archived=True) bookmark2 = self.setup_bookmark(is_archived=True) self.setup_bookmark() self.setup_bookmark() self.setup_bookmark() query = queries.query_archived_bookmarks( self.get_or_create_test_user(), '') self.assertQueryResult(query, [[bookmark1, bookmark2]])
def test_query_archived_bookmarks_should_only_return_user_owned_bookmarks( self): other_user = User.objects.create_user('otheruser', '*****@*****.**', 'password123') owned_bookmarks = [ self.setup_bookmark(is_archived=True), self.setup_bookmark(is_archived=True), self.setup_bookmark(is_archived=True), ] self.setup_bookmark(is_archived=True, user=other_user) self.setup_bookmark(is_archived=True, user=other_user) self.setup_bookmark(is_archived=True, user=other_user) query = queries.query_archived_bookmarks(self.user, '') self.assertQueryResult(query, [owned_bookmarks])