Пример #1
0
 def test_03_get_engine(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engines = client.engines
         for eng in engines:
             eng2 = client.engines[eng.id]
             self.assertEqual(eng2.name, eng.name)
Пример #2
0
 def test_03_get_engine(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engines = client.engines
         for eng in engines:
             eng2 = client.engines[eng.id]
             self.assertEqual(eng2.name, eng.name)
Пример #3
0
    def test_21_build_payload(self):
        with self.start_server(app):
            client = silota.from_key(SILOTA_TEST_API_KEY)
            engines = client.engines

            with self.start_search_server(search_app):
                for eng in engines:
                    payload = eng.build_payload()
                    print payload
Пример #4
0
    def test_21_build_payload(self):
        with self.start_server(app):
            client = silota.from_key(SILOTA_TEST_API_KEY)
            engines = client.engines

            with self.start_search_server(search_app):
                for eng in engines:
                    payload = eng.build_payload()
                    print payload
Пример #5
0
 def test_09_get_schema(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         topic = client.engines[VALID_ENGINE_ID].topics[VALID_TOPIC_ID]
         schema = topic.schema
         for col in schema:
             self.assertTrue('name' in col)
             self.assertTrue('type' in col)
             self.assertTrue('search_enabled' in col)
             self.assertTrue('result_enabled' in col)
Пример #6
0
 def test_09_get_schema(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         topic = client.engines[VALID_ENGINE_ID].topics[VALID_TOPIC_ID]
         schema = topic.schema
         for col in schema:
             self.assertTrue('name' in col)
             self.assertTrue('type' in col)
             self.assertTrue('search_enabled' in col)
             self.assertTrue('result_enabled' in col)
Пример #7
0
 def test_06_get_topics(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engines = client.engines
         for eng in engines:
             topics = eng.topics
             if eng.id == 1403592042880088015:
                 self.assertEqual(len(topics), 1)
             else:
                 self.assertEqual(len(topics), 0)
Пример #8
0
 def test_06_get_topics(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engines = client.engines
         for eng in engines:
             topics = eng.topics
             if eng.id == 1403592042880088015:
                 self.assertEqual(len(topics), 1)
             else:
                 self.assertEqual(len(topics), 0)
Пример #9
0
    def test_15_get_documents(self):
        with self.start_server(app):
            client = silota.from_key(SILOTA_TEST_API_KEY)
            topic = client.engines[VALID_ENGINE_ID].topics[VALID_TOPIC_ID]
            documents = topic.documents
            self.assertEqual(len(documents), 0)

            topic.documents.add(**{'name': 'John Smith', 'bio': 'programmer'})
            self.assertEqual(len(topic.documents), 1)
            self.assertEqual(topic.documents[0].name, 'John Smith')
            self.assertEqual(topic.documents[0].bio, 'programmer')

            topic.documents.add(**{'name': 'Jane Doe', 'bio': 'architect'})
            self.assertEqual(len(topic.documents), 2)
Пример #10
0
    def test_15_get_documents(self):
        with self.start_server(app):
            client = silota.from_key(SILOTA_TEST_API_KEY)
            topic = client.engines[VALID_ENGINE_ID].topics[VALID_TOPIC_ID]
            documents = topic.documents
            self.assertEqual(len(documents), 0)

            topic.documents.add(**{'name': 'John Smith',
                                 'bio': 'programmer'})
            self.assertEqual(len(topic.documents), 1)
            self.assertEqual(topic.documents[0].name, 'John Smith')
            self.assertEqual(topic.documents[0].bio, 'programmer')

            topic.documents.add(**{'name': 'Jane Doe',
                                 'bio': 'architect'})
            self.assertEqual(len(topic.documents), 2)
Пример #11
0
 def test_07_get_wrong_topic(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engine = client.engines[VALID_ENGINE_ID]
         with self.assertRaises(KeyError):
             topic = engine.topics[2332322]
Пример #12
0
 def test_04_get_wrong_engine(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         with self.assertRaises(KeyError):
             engine = client.engines[74983342]
Пример #13
0
 def test_02_right_auth(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engines = client.engines
         self.assertEquals(len(engines), 2)
Пример #14
0
 def test_02_right_auth(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engines = client.engines
         self.assertEquals(len(engines), 2)
Пример #15
0
 def test_01_wrong_auth(self):
     with self.start_server(app):
         client = silota.from_key('foo')
         with self.assertRaises(HTTPError):
             engines = client.engines
Пример #16
0
 def test_01_wrong_auth(self):
     with self.start_server(app):
         client = silota.from_key('foo')
         with self.assertRaises(HTTPError):
             engines = client.engines
Пример #17
0
 def test_07_get_wrong_topic(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         engine = client.engines[VALID_ENGINE_ID]
         with self.assertRaises(KeyError):
             topic = engine.topics[2332322]
Пример #18
0
 def test_04_get_wrong_engine(self):
     with self.start_server(app):
         client = silota.from_key(SILOTA_TEST_API_KEY)
         with self.assertRaises(KeyError):
             engine = client.engines[74983342]