Support CatalogId in create_database (#5339)
This commit is contained in:
parent
7681fe8706
commit
a9372c2fbc
@ -21,6 +21,8 @@ class GlueResponse(BaseResponse):
|
||||
def create_database(self):
|
||||
database_input = self.parameters.get("DatabaseInput")
|
||||
database_name = database_input.get("Name")
|
||||
if "CatalogId" in self.parameters:
|
||||
database_input["CatalogId"] = self.parameters.get("CatalogId")
|
||||
self.glue_backend.create_database(database_name, database_input)
|
||||
return ""
|
||||
|
||||
|
@ -12,10 +12,14 @@ def create_database_input(database_name):
|
||||
return database_input
|
||||
|
||||
|
||||
def create_database(client, database_name, database_input=None):
|
||||
def create_database(client, database_name, database_input=None, catalog_id=None):
|
||||
if database_input is None:
|
||||
database_input = create_database_input(database_name)
|
||||
return client.create_database(DatabaseInput=database_input)
|
||||
|
||||
database_kwargs = {"DatabaseInput": database_input}
|
||||
if catalog_id is not None:
|
||||
database_kwargs["CatalogId"] = catalog_id
|
||||
return client.create_database(**database_kwargs)
|
||||
|
||||
|
||||
def get_database(client, database_name):
|
||||
|
@ -11,6 +11,7 @@ import pytz
|
||||
from freezegun import freeze_time
|
||||
|
||||
from moto import mock_glue, settings
|
||||
from moto.core import ACCOUNT_ID
|
||||
from . import helpers
|
||||
|
||||
|
||||
@ -22,8 +23,9 @@ FROZEN_CREATE_TIME = datetime(2015, 1, 1, 0, 0, 0)
|
||||
def test_create_database():
|
||||
client = boto3.client("glue", region_name="us-east-1")
|
||||
database_name = "myspecialdatabase"
|
||||
database_catalog_id = ACCOUNT_ID
|
||||
database_input = helpers.create_database_input(database_name)
|
||||
helpers.create_database(client, database_name, database_input)
|
||||
helpers.create_database(client, database_name, database_input, database_catalog_id)
|
||||
|
||||
response = helpers.get_database(client, database_name)
|
||||
database = response["Database"]
|
||||
@ -38,7 +40,7 @@ def test_create_database():
|
||||
database_input.get("CreateTableDefaultPermissions")
|
||||
)
|
||||
database.get("TargetDatabase").should.equal(database_input.get("TargetDatabase"))
|
||||
database.get("CatalogId").should.equal(database_input.get("CatalogId"))
|
||||
database.get("CatalogId").should.equal(database_catalog_id)
|
||||
|
||||
|
||||
@mock_glue
|
||||
|
Loading…
Reference in New Issue
Block a user