Esempio n. 1
0
    def test_create_search_documents(self):
        search_documents = []
        batch_mock = self._create_mock_match(search_documents)(None, 1000)

        self.route1.geometry = DocumentGeometry()
        self.route1.geometry.lon_lat = \
            '{"type": "Point", "coordinates": [6, 46]}'
        create_search_documents('r', [self.route1], batch_mock)
        doc = search_documents[0]

        self.assertEqual(doc['_op_type'], 'index')
        self.assertEqual(doc['_id'], self.route1.document_id)
        self.assertEqual(doc['title_en'], 'Mont Blanc : Face N')
        # self.assertEqual(doc['description_en'], '...')
        self.assertEqual(doc['geom'], [6, 46])
Esempio n. 2
0
    def test_create_search_documents_user_profile(self):
        search_documents = []
        batch_mock = self._create_mock_match(search_documents)(None, 1000)

        document_id = global_userids['contributor']
        user_profile = self.session.query(UserProfile).get(document_id)

        create_search_documents('u', [user_profile], batch_mock)
        doc = search_documents[0]

        self.assertEqual(doc['_op_type'], 'index')
        self.assertEqual(doc['_id'], document_id)
        self.assertEqual(doc['title_en'], 'Contributor contributor')
        # self.assertEqual(doc['description_en'], 'Me')
        self.assertEqual(doc['title_fr'], 'Contributor contributor')
Esempio n. 3
0
    def test_create_search_documents(self):
        search_documents = []
        batch_mock = self._create_mock_match(search_documents)(None, 1000)

        self.route1.geometry = DocumentGeometry()
        self.route1.geometry.lon_lat = \
            '{"type": "Point", "coordinates": [6, 46]}'
        create_search_documents('r', [self.route1], batch_mock)
        doc = search_documents[0]

        self.assertEqual(doc['_op_type'], 'index')
        self.assertEqual(doc['_id'], self.route1.document_id)
        self.assertEqual(doc['title_en'], 'Mont Blanc : Face N')
        # self.assertEqual(doc['description_en'], '...')
        self.assertEqual(doc['geom'], [6, 46])
Esempio n. 4
0
    def test_create_search_documents_user_profile(self):
        search_documents = []
        batch_mock = self._create_mock_match(search_documents)(None, 1000)

        document_id = global_userids['contributor']
        user_profile = self.session.query(UserProfile).get(document_id)

        create_search_documents('u', [user_profile], batch_mock)
        doc = search_documents[0]

        self.assertEqual(doc['_op_type'], 'index')
        self.assertEqual(doc['_id'], document_id)
        self.assertEqual(doc['title_en'], 'contributor Contributor')
        self.assertEqual(doc['description_en'], 'Me')
        self.assertEqual(doc['title_fr'], 'contributor Contributor')
        self.assertEqual(doc['description_fr'], 'Moi')