Exemplo n.º 1
0
    def test_save_to_search_index(self):
        entry = EntryFactory.create(published=True)
        job = self.queue.enqueue(save_to_search_index, 'writings.Entry', entry.id)
        doc_id = calculate_doc_id('writings.Entry', entry.id)

        self.assertEqual(job.status, 'finished')
        self.assertEqual(job.return_value, doc_id)
Exemplo n.º 2
0
    def test_save_to_search_index(self):
        entry = EntryFactory.create(published=True)
        job = self.queue.enqueue(save_to_search_index, 'writings.Entry',
                                 entry.id)
        doc_id = calculate_doc_id('writings.Entry', entry.id)

        self.assertEqual(job.status, 'finished')
        self.assertEqual(job.return_value, doc_id)
Exemplo n.º 3
0
    def test_handle_model_post_save(self):
        # mocks.patch doesn't work with rq. Not sure how to test further
        entry = EntryFactory.create(published=True)
        job = self.queue.enqueue(handle_model_post_save, 'writings.Entry', entry.id)
        doc_id = calculate_doc_id('writings.Entry', entry.id)

        self.assertEqual(job.status, 'finished')
        self.assertEqual(job.return_value, doc_id)
Exemplo n.º 4
0
    def test_handle_model_post_save(self):
        # mocks.patch doesn't work with rq. Not sure how to test further
        entry = EntryFactory.create(published=True)
        job = self.queue.enqueue(handle_model_post_save, 'writings.Entry',
                                 entry.id)
        doc_id = calculate_doc_id('writings.Entry', entry.id)

        self.assertEqual(job.status, 'finished')
        self.assertEqual(job.return_value, doc_id)
Exemplo n.º 5
0
    def test_handle_model_post_delete(self):
        entry = EntryFactory.create(published=True)
        entry_id = entry.id
        doc_id = calculate_doc_id('writings.Entry', entry_id)

        save_job = self.queue.enqueue(save_to_search_index, 'writings.Entry', entry_id)

        self.assertEqual(save_job.status, 'finished')
        self.assertEqual(save_job.return_value, doc_id)

        entry.delete()
        job = self.queue.enqueue(handle_model_post_delete, 'writings.Entry', entry_id)

        self.assertEqual(job.status, 'finished')
        self.assertEqual(job.return_value, doc_id)
Exemplo n.º 6
0
    def test_handle_model_post_delete(self):
        entry = EntryFactory.create(published=True)
        entry_id = entry.id
        doc_id = calculate_doc_id('writings.Entry', entry_id)

        save_job = self.queue.enqueue(save_to_search_index, 'writings.Entry',
                                      entry_id)

        self.assertEqual(save_job.status, 'finished')
        self.assertEqual(save_job.return_value, doc_id)

        entry.delete()
        job = self.queue.enqueue(handle_model_post_delete, 'writings.Entry',
                                 entry_id)

        self.assertEqual(job.status, 'finished')
        self.assertEqual(job.return_value, doc_id)
Exemplo n.º 7
0
    def test_calculate_doc_id(self):
        doc_id = calculate_doc_id('writings.Entry', 411)

        label, pk = doc_id.split(DOC_ID_SEPARATOR)
        self.assertEqual(label, 'writings.Entry')
        self.assertEqual(pk, '411')
Exemplo n.º 8
0
    def test_calculate_doc_id(self):
        doc_id = calculate_doc_id('writings.Entry', 411)

        label, pk = doc_id.split(DOC_ID_SEPARATOR)
        self.assertEqual(label, 'writings.Entry')
        self.assertEqual(pk, '411')