def test_create_operator_with_wrong_parameters( self, project_id, location, instance_name, database_type, use_proxy, use_ssl, sql, message, get_connections, ): uri = ( "gcpcloudsql://*****:*****@127.0.0.1:3200/testdb?" "database_type={database_type}&" "project_id={project_id}&location={location}&instance={instance_name}&" "use_proxy={use_proxy}&use_ssl={use_ssl}".format( database_type=database_type, project_id=project_id, location=location, instance_name=instance_name, use_proxy=use_proxy, use_ssl=use_ssl, ) ) self._setup_connections(get_connections, uri) with self.assertRaises(AirflowException) as cm: op = CloudSQLExecuteQueryOperator(sql=sql, task_id='task_id') op.execute(None) err = cm.exception self.assertIn(message, str(err))
def test_create_operator_with_too_long_unix_socket_path( self, get_connections): uri = "gcpcloudsql://*****:*****@127.0.0.1:3200/testdb?database_type=postgres&" \ "project_id=example-project&location=europe-west1&" \ "instance=" \ "test_db_with_long_name_a_bit_above" \ "_the_limit_of_UNIX_socket_asdadadasadasd&" \ "use_proxy=True&sql_proxy_use_tcp=False" self._setup_connections(get_connections, uri) operator = CloudSQLExecuteQueryOperator(sql=['SELECT * FROM TABLE'], task_id='task_id') with self.assertRaises(AirflowException) as cm: operator.execute(None) err = cm.exception self.assertIn("The UNIX socket path length cannot exceed", str(err))