Пример #1
0
    def test_create_search_index_doc(self, scrape):
        # It builds the base doc object
        scrape.return_value = 'Fake content'
        doc = search.create_search_index_doc(self.page)
        self.assertEqual(
            doc, {
                'document_id': 123,
                'title': 'Mock page',
                'path': 'https://www.fec.gov/mock/',
                'content': 'Fake content',
                'created': '2017-06-01-000000',
                'promote': 'false',
                'language': 'en',
            })

        # It calls scrape_page_content with the correct url
        scrape.assert_called_with('https://www.fec.gov/mock/')
Пример #2
0
 def test_create_index_doc_edited(self, scrape):
     # It adds doc['changed'] if the page was edited
     page = MockPage(add_latest_revision=True)
     doc = search.create_search_index_doc(page)
     self.assertEqual(doc['changed'], '2017-06-02-000000')
Пример #3
0
 def test_create_index_doc_with_description(self, scrape):
     # It adds description if the page has one
     page = MockPage(add_description=True)
     doc = search.create_search_index_doc(page)
     self.assertEqual(doc['description'], 'Fake description')