Пример #1
0
    def test_queryset_update(self):
        # update some contents
        self.assertEqual(M.query(subject__prefix='amaz').count(), 1)
        Article.objects.filter(pk=3).update(subject='hey #tgif')

        # reindex all
        M.run_index_all()
        # refresh index
        M.refresh_index()

        # should
        self.assertEqual(M.query(subject__prefix='amaz').count(), 0)
        self.assertEqual(M.query(subject__match='#tgif').count(), 1)

        # update some contents
        self.assertEqual(M.query(content__term='yo').count(), 1)
        Article.objects.filter(pk=3).update(content='monday uh!')

        # refresh index
        M.refresh_index()

        self.assertEqual(M.query(content__term='yo').count(), 0)
        self.assertEqual(M.query(content__term='monday').count(), 1)
Пример #2
0
    def setUp(self):
        super(BaseTest, self).setUp()

        self.louise = User.objects.get(pk=2)
        self.florent = User.objects.get(pk=1)
        self. search_fields = ['author.username',
                               'author.email',
                               'category.id',
                               'category.name',
                               'created_at',
                               'subject',
                               'content',
                               'status',
                               'contributors',
                               'library',
                               'library.name',
                               'library.number_of_books',
                               'q',
                               's',
                               'trololo']
        self.mapping_type = M
        M.update_mapping()
        M.run_index_all()
        M.refresh_index()