SageMaker: correct describe_model_package_group does not exist msg (#7246)
This commit is contained in:
parent
876cfeaa9c
commit
a04ef58386
1
Makefile
1
Makefile
@ -32,6 +32,7 @@ lint:
|
|||||||
|
|
||||||
format:
|
format:
|
||||||
black moto/ tests/
|
black moto/ tests/
|
||||||
|
ruff --fix moto/ tests/
|
||||||
|
|
||||||
test-only:
|
test-only:
|
||||||
rm -f .coverage
|
rm -f .coverage
|
||||||
|
@ -3334,8 +3334,14 @@ class SageMakerModelBackend(BaseBackend):
|
|||||||
) -> ModelPackageGroup:
|
) -> ModelPackageGroup:
|
||||||
model_package_group = self.model_package_groups.get(model_package_group_name)
|
model_package_group = self.model_package_groups.get(model_package_group_name)
|
||||||
if model_package_group is None:
|
if model_package_group is None:
|
||||||
|
model_package_group_arn = arn_formatter(
|
||||||
|
region_name=self.region_name,
|
||||||
|
account_id=self.account_id,
|
||||||
|
_type="model-package-group",
|
||||||
|
_id=f"{model_package_group_name}",
|
||||||
|
)
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
f"Model package group {model_package_group_name} not found"
|
f"ModelPackageGroup {model_package_group_arn} does not exist."
|
||||||
)
|
)
|
||||||
return model_package_group
|
return model_package_group
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ from datetime import datetime
|
|||||||
from unittest import SkipTest
|
from unittest import SkipTest
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
|
import pytest
|
||||||
|
from botocore.exceptions import ClientError
|
||||||
from dateutil.tz import tzutc # type: ignore
|
from dateutil.tz import tzutc # type: ignore
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
@ -193,6 +195,21 @@ def test_describe_model_package_group():
|
|||||||
assert resp["CreationTime"] == datetime(2020, 1, 1, 0, 0, 0, tzinfo=tzutc())
|
assert resp["CreationTime"] == datetime(2020, 1, 1, 0, 0, 0, tzinfo=tzutc())
|
||||||
|
|
||||||
|
|
||||||
|
@mock_sagemaker
|
||||||
|
def test_describe_model_package_group_not_exists():
|
||||||
|
if settings.TEST_SERVER_MODE:
|
||||||
|
raise SkipTest("Can't freeze time in ServerMode")
|
||||||
|
client = boto3.client("sagemaker", region_name="eu-west-1")
|
||||||
|
|
||||||
|
with pytest.raises(ClientError) as e:
|
||||||
|
client.describe_model_package_group(
|
||||||
|
ModelPackageGroupName="test-model-package-group"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert e.value.response["Error"]["Code"] == "ValidationException"
|
||||||
|
assert "does not exist" in e.value.response["Error"]["Message"]
|
||||||
|
|
||||||
|
|
||||||
@mock_sagemaker
|
@mock_sagemaker
|
||||||
def test_list_tags_model_package_group():
|
def test_list_tags_model_package_group():
|
||||||
region_name = "eu-west-1"
|
region_name = "eu-west-1"
|
||||||
|
Loading…
Reference in New Issue
Block a user