def test_search_function_multiple(self): """ Test basic search function is independent each time """ G(TestModelPost, title="This is a one post.", slug="", author=self.staff) G(TestModelPost, title="This is a one post called hello.", slug="", author=self.staff) G(TestModelPost, title="This is a two post.", slug="", author=self.staff) result = search_redis("one") self.assertEquals(result, [{'model': 'tests.testmodelpost', 'title': 'This is a one post called hello.', 'get_absolute_url': '/blog/post/this-is-a-one-post-called-hello/', 'id': 2, 'slug': 'this-is-a-one-post-called-hello'}, {'model': 'tests.testmodelpost', 'title': 'This is a one post.', 'get_absolute_url': '/blog/post/this-is-a-one-post/', 'id': 1, 'slug': 'this-is-a-one-post'}]) result2 = search_redis("two") self.assertEquals(result2, [{'model': 'tests.testmodelpost', 'title': 'This is a two post.', 'get_absolute_url': '/blog/post/this-is-a-two-post/', 'id': 3, 'slug': 'this-is-a-two-post'}])
def test_search_function(self): """ Test basic search function - top search should have the highest hit count. """ G(TestModelPost, title="This is a python post.", slug="", author=self.staff) G(TestModelPost, title="This is a post called attempt post.", slug="", author=self.staff) G(TestModelPost, title="This is a test attempt post.", slug="", author=self.staff) G(TestModelPost, title="This is a test case.", slug="", author=self.staff) G(TestModelPost, title="This is a test.", slug="", author=self.staff) result = search_redis("post attempt") self.assertEquals(result, [{'model': 'tests.testmodelpost', 'title': 'This is a post called attempt post.', 'get_absolute_url': '/blog/post/this-is-a-post-called-attempt-post/', 'id': 2, 'slug': 'this-is-a-post-called-attempt-post'}, {'model': 'tests.testmodelpost', 'title': 'This is a test attempt post.', 'get_absolute_url': '/blog/post/this-is-a-test-attempt-post/', 'id': 3, 'slug': 'this-is-a-test-attempt-post'}, {'model': 'tests.testmodelpost', 'title': 'This is a python post.', 'get_absolute_url': '/blog/post/this-is-a-python-post/', 'id': 1, 'slug': 'this-is-a-python-post'}])