예제 #1
0
    def setUp(self):
        super().setUp()
        self.published_entry_count = 102
        self.published_project_count = 101
        EntryFactory.create_batch(self.published_entry_count, published=True)
        ProjectFactory.create_batch(self.published_project_count,
                                    published=True)
        self.unpublished_entry_count = 14
        self.unpublished_project_count = 6
        EntryFactory.create_batch(self.unpublished_entry_count,
                                  published=False)
        ProjectFactory.create_batch(self.unpublished_project_count,
                                    published=False)

        from django.conf import settings
        self.SEARCH = getattr(settings, 'SEARCH')
        self.PUBLISH_FILTER_ENABLED = getattr(settings,
                                              'PUBLISH_FILTER_ENABLED', True)
예제 #2
0
    def test_rebuild_index_no_args(self):
        EntryFactory.create_batch(100, published=True)
        ProjectFactory.create_batch(100, published=True)
        num_base_people = 100
        num_employed_people = 120
        total_num_people = num_base_people + num_employed_people
        PersonFactory.create_batch(num_base_people, published=True)
        PositionFactory.create_batch(num_employed_people)

        out = io.StringIO()

        call_command('rebuild_index', stdout=out)

        self.assertIn(
            "Reindexed {} '{}' documents".format(
                100, EntryFactory._meta.model._meta.label), out.getvalue())
        self.assertIn(
            "Reindexed {} '{}' documents".format(
                100, ProjectFactory._meta.model._meta.label), out.getvalue())
        self.assertIn(
            "Reindexed {} '{}' documents".format(
                total_num_people, PersonFactory._meta.model._meta.label),
            out.getvalue())
예제 #3
0
    def test_index_model_multiple_models(self):
        entry_objects = EntryFactory.create_batch(30, published=True)
        project_objects = ProjectFactory.create_batch(20, published=True)

        job = self.queue.enqueue(index_model,
                                 EntryFactory._meta.model._meta.label)

        self.assertEqual(job.result, (30, []))
        self.assertEqual(job.get_status(), 'finished')

        job = self.queue.enqueue(index_model,
                                 ProjectFactory._meta.model._meta.label)

        self.assertEqual(job.result, (20, []))
        self.assertEqual(job.get_status(), 'finished')

        self.index.refresh()

        self.assertEqual(
            len(entry_objects) + len(project_objects), self.search.count())