def test_deleted(self): # Nothing exists before the test starts eq_(ThreadMappingType.search().count(), 0) # Creating a new Thread does create a new document in the index. new_thread = ThreadFactory() self.refresh() eq_(ThreadMappingType.search().count(), 1) # Deleting the thread deletes the document in the index. new_thread.delete() self.refresh() eq_(ThreadMappingType.search().count(), 0)
def test_added(self): # Nothing exists before the test starts eq_(ThreadMappingType.search().count(), 0) # Creating a new Thread does create a new document in the index. new_thread = ThreadFactory() self.refresh() eq_(ThreadMappingType.search().count(), 1) # Saving a new post in a thread doesn't create a new # document in the index. Therefore, the count remains 1. # # TODO: This is ambiguous: it's not clear whether we correctly # updated the document in the index or whether the post_save # hook didn't kick off. Need a better test. PostFactory(thread=new_thread) self.refresh() eq_(ThreadMappingType.search().count(), 1)
def test_deleted(self): new_thread = thread() eq_(ThreadMappingType.search().count(), 0) # Saving a new Thread does create a new document in the # index. new_thread.save() self.refresh() eq_(ThreadMappingType.search().count(), 1) new_post = post(thread=new_thread) eq_(ThreadMappingType.search().count(), 1) new_post.save() self.refresh() eq_(ThreadMappingType.search().count(), 1) new_thread.delete() self.refresh() eq_(ThreadMappingType.search().count(), 0)
def test_thread_is_reindexed_on_username_change(self): search = ThreadMappingType.search() u = UserFactory(username="******") ThreadFactory(creator=u, title="Hello") self.refresh() eq_(search.query(post_title="hello")[0]["post_author_ord"], ["dexter"]) # Change the username and verify the index. u.username = "******" u.save() self.refresh() eq_(search.query(post_title="hello")[0]["post_author_ord"], ["walter"])
def test_thread_is_reindexed_on_username_change(self): search = ThreadMappingType.search() u = UserFactory(username='******') ThreadFactory(creator=u, title=u'Hello') self.refresh() eq_(search.query(post_title='hello')[0]['post_author_ord'], [u'dexter']) # Change the username and verify the index. u.username = '******' u.save() self.refresh() eq_(search.query(post_title='hello')[0]['post_author_ord'], [u'walter'])
def test_thread_is_reindexed_on_username_change(self): search = ThreadMappingType.search() u = UserFactory(username='******') ThreadFactory(creator=u, title='Hello') self.refresh() eq_(search.query(post_title='hello')[0]['post_author_ord'], ['dexter']) # Change the username and verify the index. u.username = '******' u.save() self.refresh() eq_(search.query(post_title='hello')[0]['post_author_ord'], ['walter'])
def test_added(self): new_thread = thread() eq_(ThreadMappingType.search().count(), 0) # Saving a new Thread does create a new document in the # index. new_thread.save() self.refresh() eq_(ThreadMappingType.search().count(), 1) new_post = post(thread=new_thread) eq_(ThreadMappingType.search().count(), 1) new_post.save() self.refresh() # Saving a new post in a thread doesn't create a new # document in the index. Therefore, the count remains 1. # # TODO: This is ambiguous: it's not clear whether we correctly # updated the document in the index or whether the post_save # hook didn't kick off. Need a better test. eq_(ThreadMappingType.search().count(), 1)
def test_thread_is_reindexed_on_username_change(self): search = ThreadMappingType.search() u = user(username='******', save=True) t = thread(creator=u, title=u'Hello', save=True) post(author=u, thread=t, save=True) self.refresh() eq_( search.query(post_title='hello')[0]['post_author_ord'], [u'dexter']) # Change the username and verify the index. u.username = '******' u.save() self.refresh() eq_( search.query(post_title='hello')[0]['post_author_ord'], [u'walter'])