Example #1
0
 def test_auth(self, mock_elasticsearch):
     """
         DBAPI: test Elasticsearch is called with user password
     """
     mock_elasticsearch.return_value = None
     connect(host="localhost", user="******", password="******")
     mock_elasticsearch.assert_called_once_with("http://localhost:9200/",
                                                http_auth=("user",
                                                           "password"))
Example #2
0
 def test_close(self):
     """
     DBAPI: Test connection failed
     """
     conn = connect(host="localhost")
     conn.close()
     with self.assertRaises(Error):
         conn.close()
Example #3
0
 def test_connect_failed(self):
     """
     DBAPI: Test connection failed
     """
     conn = connect(host="unknown")
     curs = conn.cursor()
     with self.assertRaises(OperationalError):
         curs.execute("select Carrier from flights").fetchall()
     conn.close()
Example #4
0
def connect_and_load(packages, warning_types):
    """
	loads all the warnings for the specified packages

	Arguments
	---------
	packages : the list package you want warnings for (do not specify versions)
	warning_types : the Aura warning types you care about

	Returns
	---------
	warnings : a dict of warnings, by package name
	"""
    conn = connect(host=HOST)
    curs = conn.cursor()

    warnings = {}
    for package in packages:
        warnings[package] = get_warnings(package, warning_types, curs)

    return warnings
Example #5
0
    def get_conn(self) -> ESConnection:
        """Returns a elasticsearch connection object"""
        conn_id = getattr(self, self.conn_name_attr)
        conn = self.connection or self.get_connection(conn_id)

        conn_args = dict(
            host=conn.host,
            port=conn.port,
            user=conn.login or None,
            password=conn.password or None,
            scheme=conn.schema or "http",
        )

        if conn.extra_dejson.get('http_compress', False):
            conn_args["http_compress"] = bool(["http_compress"])

        if conn.extra_dejson.get('timeout', False):
            conn_args["timeout"] = conn.extra_dejson["timeout"]

        conn = connect(**conn_args)

        return conn
Example #6
0
 def setUp(self):
     self.conn = connect(host="localhost")
     self.cursor = self.conn.cursor()