Exemplo n.º 1
0
 def test_elastic_connect(self):
     """Test the create elastic index."""
     response_body = {}
     httpretty.register_uri(httpretty.GET, 'http://127.0.0.1:9200/',
                            body=dumps(response_body),
                            content_type='application/json')
     try_es_connect()
     self.assertEqual(httpretty.last_request().method, 'GET')
Exemplo n.º 2
0
def create_tables():
    """Create the tables for the objects if they exist."""
    try_db_connect()
    try_es_connect()
    create_elastic_index()
    for obj in ORM_OBJECTS:
        if not obj.table_exists():
            obj.create_table()
            obj.create_elastic_mapping()
    DB.close()
Exemplo n.º 3
0
 def test_elastic_connect(self):
     """
     Test the create elastic index
     """
     response_body = {}
     httpretty.register_uri(httpretty.GET, "http://127.0.0.1:9200/_stats",
                            body=dumps(response_body),
                            content_type="application/json")
     try_es_connect()
     self.assertEqual(httpretty.last_request().method, "GET")
Exemplo n.º 4
0
def create_tables():
    """
    Create the tables for the objects if they exist.
    """
    try_db_connect()
    try_es_connect()
    create_elastic_index()
    for obj in ORM_OBJECTS:
        if not obj.table_exists():
            obj.create_table()
            obj.create_elastic_mapping()
    DB.close()
Exemplo n.º 5
0
 def test_error_es_connect(self):
     """
     Test the create elastic index
     """
     httpretty.register_uri(httpretty.GET, "http://127.0.0.1:9200/_stats",
                            body="Trying to connect",
                            status=404)
     #pylint: disable=broad-except
     try:
         try_es_connect()
     except Exception, ex:
         self.assertEqual(httpretty.last_request().method, "GET")
         self.assertEqual(str(ex), "try_es_connect: 404\n")
Exemplo n.º 6
0
 def test_error_es_connect(self):
     """Test the create elastic index."""
     hit_exception = False
     httpretty.register_uri(httpretty.GET, 'http://127.0.0.1:9200/',
                            body='Trying to connect',
                            status=404)
     # pylint: disable=broad-except
     try:
         try_es_connect()
     except Exception as ex:
         hit_exception = True
         self.assertEqual(httpretty.last_request().method, 'GET')
         self.assertEqual(str(ex), 'TransportError(404, u\'Trying to connect\')')
     # pylint: enable=broad-except
     self.assertTrue(hit_exception)