Skip to content

Commit

Permalink
Data Brew: Update Recipe Latest Working Version Create Date (#7667)
Browse files Browse the repository at this point in the history
  • Loading branch information
runstache committed May 11, 2024
1 parent b21ae7c commit 9394878
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions moto/databrew/models.py
Expand Up @@ -477,6 +477,9 @@ def publish(self, description: Optional[str] = None) -> None:
del self.versions[self.latest_working.version]
self.versions[self.latest_published.version] = self.latest_published
self.latest_working.version = self.latest_published.version + 0.1

if self.latest_published.published_date:
self.latest_working.created_time = self.latest_published.published_date
self.versions[self.latest_working.version] = self.latest_working

def update(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_databrew/test_databrew_recipes.py
Expand Up @@ -374,6 +374,12 @@ def test_publish_recipe(recipe_name):
assert recipe["PublishedDate"] > dt_before_publish
first_published_date = recipe["PublishedDate"]

# Latest Working should have created date == publish date
working_response = client.describe_recipe(
Name=recipe_name, RecipeVersion="LATEST_WORKING"
)
assert working_response["CreateDate"] == first_published_date

# Publish the recipe a 2nd time
publish_response = client.publish_recipe(Name=recipe_name, Description="2nd desc")
assert publish_response["Name"] == recipe_name
Expand All @@ -383,6 +389,12 @@ def test_publish_recipe(recipe_name):
assert recipe["RecipeVersion"] == "2.0"
assert recipe["PublishedDate"] >= first_published_date

# Check working Created Date
working_response = client.describe_recipe(
Name=recipe_name, RecipeVersion="LATEST_WORKING"
)
assert recipe["PublishedDate"] == working_response["CreateDate"]


@mock_aws
def test_publish_recipe_that_does_not_exist():
Expand Down

0 comments on commit 9394878

Please sign in to comment.