Skip to content

Commit

Permalink
Databrew: support for returning ResourceArn in databrew datasets (get…
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-sanders committed Jun 14, 2022
1 parent 21189ef commit 7882505
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions moto/databrew/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def create_dataset(

dataset = FakeDataset(
self.region_name,
self.account_id,
dataset_name,
dataset_format,
dataset_format_options,
Expand Down Expand Up @@ -432,6 +433,7 @@ class FakeDataset(BaseModel):
def __init__(
self,
region_name,
account_id,
dataset_name,
dataset_format,
dataset_format_options,
Expand All @@ -440,6 +442,7 @@ def __init__(
tags,
):
self.region_name = region_name
self.account_id = account_id
self.name = dataset_name
self.format = dataset_format
self.format_options = dataset_format_options
Expand All @@ -448,6 +451,12 @@ def __init__(
self.created_time = datetime.now()
self.tags = tags

@property
def resource_arn(self):
return (
f"arn:aws:databrew:{self.region_name}:{self.account_id}:dataset/{self.name}"
)

def as_dict(self):
return {
"Name": self.name,
Expand All @@ -457,6 +466,7 @@ def as_dict(self):
"PathOptions": self.path_options,
"CreateTime": self.created_time.isoformat(),
"Tags": self.tags or dict(),
"ResourceArn": self.resource_arn,
}


Expand Down
8 changes: 8 additions & 0 deletions tests/test_databrew/test_databrew_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from botocore.exceptions import ClientError

from moto import mock_databrew
from moto.core import ACCOUNT_ID


def _create_databrew_client():
Expand Down Expand Up @@ -109,6 +110,7 @@ def test_list_datasets_with_max_results():
_create_test_datasets(client, 4)
response = client.list_datasets(MaxResults=2)
response["Datasets"].should.have.length_of(2)
response["Datasets"][0].should.have.key("ResourceArn")
response.should.have.key("NextToken")


Expand Down Expand Up @@ -137,6 +139,9 @@ def test_describe_dataset():
response = _create_test_dataset(client)
dataset = client.describe_dataset(Name=response["Name"])
dataset["Name"].should.equal(response["Name"])
dataset.should.have.key("ResourceArn").equal(
f"arn:aws:databrew:us-west-1:{ACCOUNT_ID}:dataset/{response['Name']}"
)
# endregion

# region JSON test
Expand Down Expand Up @@ -232,6 +237,9 @@ def test_update_dataset():
dataset = client.describe_dataset(Name=response["Name"])
dataset["Name"].should.equal(response["Name"])
dataset["Format"].should.equal("TEST")
dataset.should.have.key("ResourceArn").equal(
f"arn:aws:databrew:us-west-1:{ACCOUNT_ID}:dataset/{response['Name']}"
)


@mock_databrew
Expand Down

0 comments on commit 7882505

Please sign in to comment.