Port test suite from nose to pytest.
This just eliminates all errors on the tests collection. Elimination of failures is left to the next commit.
This commit is contained in:
parent
47dbad291e
commit
77dc60ea97
146 changed files with 1172 additions and 1277 deletions
|
|
@ -3,12 +3,12 @@ from __future__ import unicode_literals
|
|||
|
||||
import datetime
|
||||
import boto3
|
||||
from botocore.exceptions import ClientError, ParamValidationError
|
||||
from botocore.exceptions import ClientError
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_sagemaker
|
||||
from moto.sts.models import ACCOUNT_ID
|
||||
from nose.tools import assert_true, assert_equal, assert_raises
|
||||
import pytest
|
||||
|
||||
TEST_REGION_NAME = "us-east-1"
|
||||
FAKE_ROLE_ARN = "arn:aws:iam::{}:role/FakeRole".format(ACCOUNT_ID)
|
||||
|
|
@ -33,14 +33,12 @@ def test_create_endpoint_config():
|
|||
]
|
||||
|
||||
endpoint_config_name = "MyEndpointConfig"
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.create_endpoint_config(
|
||||
EndpointConfigName=endpoint_config_name,
|
||||
ProductionVariants=production_variants,
|
||||
)
|
||||
assert_true(
|
||||
e.exception.response["Error"]["Message"].startswith("Could not find model")
|
||||
)
|
||||
assert e.exception.response["Error"]["Message"].startswith("Could not find model")
|
||||
|
||||
_create_model(sagemaker, model_name)
|
||||
resp = sagemaker.create_endpoint_config(
|
||||
|
|
@ -88,22 +86,13 @@ def test_delete_endpoint_config():
|
|||
)
|
||||
|
||||
resp = sagemaker.delete_endpoint_config(EndpointConfigName=endpoint_config_name)
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.describe_endpoint_config(EndpointConfigName=endpoint_config_name)
|
||||
assert_true(
|
||||
e.exception.response["Error"]["Message"].startswith(
|
||||
"Could not find endpoint configuration"
|
||||
)
|
||||
)
|
||||
assert e.exception.response["Error"]["Message"].startswith("Could not find endpoint configuration")
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.delete_endpoint_config(EndpointConfigName=endpoint_config_name)
|
||||
assert_true(
|
||||
e.exception.response["Error"]["Message"].startswith(
|
||||
"Could not find endpoint configuration"
|
||||
)
|
||||
)
|
||||
pass
|
||||
assert e.exception.response["Error"]["Message"].startswith( "Could not find endpoint configuration")
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -124,16 +113,16 @@ def test_create_endpoint_invalid_instance_type():
|
|||
]
|
||||
|
||||
endpoint_config_name = "MyEndpointConfig"
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.create_endpoint_config(
|
||||
EndpointConfigName=endpoint_config_name,
|
||||
ProductionVariants=production_variants,
|
||||
)
|
||||
assert_equal(e.exception.response["Error"]["Code"], "ValidationException")
|
||||
assert e.exception.response["Error"]["Code"] == "ValidationException"
|
||||
expected_message = "Value '{}' at 'instanceType' failed to satisfy constraint: Member must satisfy enum value set: [".format(
|
||||
instance_type
|
||||
)
|
||||
assert_true(expected_message in e.exception.response["Error"]["Message"])
|
||||
assert expected_message in e.exception.response["Error"]["Message"]
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -141,15 +130,11 @@ def test_create_endpoint():
|
|||
sagemaker = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
|
||||
|
||||
endpoint_name = "MyEndpoint"
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.create_endpoint(
|
||||
EndpointName=endpoint_name, EndpointConfigName="NonexistentEndpointConfig"
|
||||
)
|
||||
assert_true(
|
||||
e.exception.response["Error"]["Message"].startswith(
|
||||
"Could not find endpoint configuration"
|
||||
)
|
||||
)
|
||||
assert e.exception.response["Error"]["Message"].startswith("Could not find endpoint configuration")
|
||||
|
||||
model_name = "MyModel"
|
||||
_create_model(sagemaker, model_name)
|
||||
|
|
@ -173,12 +158,12 @@ def test_create_endpoint():
|
|||
resp["EndpointName"].should.equal(endpoint_name)
|
||||
resp["EndpointConfigName"].should.equal(endpoint_config_name)
|
||||
resp["EndpointStatus"].should.equal("InService")
|
||||
assert_true(isinstance(resp["CreationTime"], datetime.datetime))
|
||||
assert_true(isinstance(resp["LastModifiedTime"], datetime.datetime))
|
||||
assert isinstance(resp["CreationTime"], datetime.datetime)
|
||||
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
|
||||
resp["ProductionVariants"][0]["VariantName"].should.equal("MyProductionVariant")
|
||||
|
||||
resp = sagemaker.list_tags(ResourceArn=resp["EndpointArn"])
|
||||
assert_equal(resp["Tags"], GENERIC_TAGS_PARAM)
|
||||
assert resp["Tags"] == GENERIC_TAGS_PARAM
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -195,17 +180,13 @@ def test_delete_endpoint():
|
|||
_create_endpoint(sagemaker, endpoint_name, endpoint_config_name)
|
||||
|
||||
sagemaker.delete_endpoint(EndpointName=endpoint_name)
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.describe_endpoint(EndpointName=endpoint_name)
|
||||
assert_true(
|
||||
e.exception.response["Error"]["Message"].startswith("Could not find endpoint")
|
||||
)
|
||||
assert e.exception.response["Error"]["Message"].startswith("Could not find endpoint")
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.delete_endpoint(EndpointName=endpoint_name)
|
||||
assert_true(
|
||||
e.exception.response["Error"]["Message"].startswith("Could not find endpoint")
|
||||
)
|
||||
assert e.exception.response["Error"]["Message"].startswith("Could not find endpoint")
|
||||
|
||||
|
||||
def _create_model(boto_client, model_name):
|
||||
|
|
@ -217,7 +198,7 @@ def _create_model(boto_client, model_name):
|
|||
},
|
||||
ExecutionRoleArn=FAKE_ROLE_ARN,
|
||||
)
|
||||
assert_equal(resp["ResponseMetadata"]["HTTPStatusCode"], 200)
|
||||
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
def _create_endpoint_config(boto_client, endpoint_config_name, model_name):
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import tests.backport_assert_raises # noqa
|
||||
from botocore.exceptions import ClientError
|
||||
from nose.tools import assert_raises
|
||||
import pytest
|
||||
from moto import mock_sagemaker
|
||||
|
||||
import sure # noqa
|
||||
|
|
@ -76,7 +75,7 @@ def test_delete_model():
|
|||
|
||||
@mock_sagemaker
|
||||
def test_delete_model_not_found():
|
||||
with assert_raises(ClientError) as err:
|
||||
with pytest.raises(ClientError) as err:
|
||||
boto3.client("sagemaker", region_name="us-east-1").delete_model(
|
||||
ModelName="blah"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import sure # noqa
|
|||
|
||||
from moto import mock_sagemaker
|
||||
from moto.sts.models import ACCOUNT_ID
|
||||
from nose.tools import assert_true, assert_equal, assert_raises
|
||||
import pytest
|
||||
|
||||
TEST_REGION_NAME = "us-east-1"
|
||||
FAKE_SUBNET_ID = "subnet-012345678"
|
||||
|
|
@ -41,26 +41,25 @@ def test_create_notebook_instance_minimal_params():
|
|||
"RoleArn": FAKE_ROLE_ARN,
|
||||
}
|
||||
resp = sagemaker.create_notebook_instance(**args)
|
||||
assert_true(resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker"))
|
||||
assert_true(resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"]))
|
||||
assert resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
|
||||
|
||||
resp = sagemaker.describe_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
assert_true(resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker"))
|
||||
assert_true(resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"]))
|
||||
assert_equal(resp["NotebookInstanceName"], NAME_PARAM)
|
||||
assert_equal(resp["NotebookInstanceStatus"], "InService")
|
||||
assert_equal(
|
||||
resp["Url"], "{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
|
||||
)
|
||||
assert_equal(resp["InstanceType"], INSTANCE_TYPE_PARAM)
|
||||
assert_equal(resp["RoleArn"], FAKE_ROLE_ARN)
|
||||
assert_true(isinstance(resp["LastModifiedTime"], datetime.datetime))
|
||||
assert_true(isinstance(resp["CreationTime"], datetime.datetime))
|
||||
assert_equal(resp["DirectInternetAccess"], "Enabled")
|
||||
assert_equal(resp["VolumeSizeInGB"], 5)
|
||||
assert resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
|
||||
assert resp["NotebookInstanceName"] == NAME_PARAM
|
||||
assert resp["NotebookInstanceStatus"] == "InService"
|
||||
assert resp["Url"] == \
|
||||
"{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
|
||||
assert resp["InstanceType"] == INSTANCE_TYPE_PARAM
|
||||
assert resp["RoleArn"] == FAKE_ROLE_ARN
|
||||
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
|
||||
assert isinstance(resp["CreationTime"], datetime.datetime)
|
||||
assert resp["DirectInternetAccess"] == "Enabled"
|
||||
assert resp["VolumeSizeInGB"] == 5
|
||||
|
||||
|
||||
# assert_equal(resp["RootAccess"], True) # ToDo: Not sure if this defaults...
|
||||
# assert resp["RootAccess"] == True # ToDo: Not sure if this defaults...
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -92,36 +91,34 @@ def test_create_notebook_instance_params():
|
|||
"RootAccess": ROOT_ACCESS_PARAM,
|
||||
}
|
||||
resp = sagemaker.create_notebook_instance(**args)
|
||||
assert_true(resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker"))
|
||||
assert_true(resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"]))
|
||||
assert resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
|
||||
|
||||
resp = sagemaker.describe_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
assert_true(resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker"))
|
||||
assert_true(resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"]))
|
||||
assert_equal(resp["NotebookInstanceName"], NAME_PARAM)
|
||||
assert_equal(resp["NotebookInstanceStatus"], "InService")
|
||||
assert_equal(
|
||||
resp["Url"], "{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
|
||||
)
|
||||
assert_equal(resp["InstanceType"], INSTANCE_TYPE_PARAM)
|
||||
assert_equal(resp["RoleArn"], FAKE_ROLE_ARN)
|
||||
assert_true(isinstance(resp["LastModifiedTime"], datetime.datetime))
|
||||
assert_true(isinstance(resp["CreationTime"], datetime.datetime))
|
||||
assert_equal(resp["DirectInternetAccess"], "Enabled")
|
||||
assert_equal(resp["VolumeSizeInGB"], VOLUME_SIZE_IN_GB_PARAM)
|
||||
# assert_equal(resp["RootAccess"], True) # ToDo: Not sure if this defaults...
|
||||
assert_equal(resp["SubnetId"], FAKE_SUBNET_ID)
|
||||
assert_equal(resp["SecurityGroups"], FAKE_SECURITY_GROUP_IDS)
|
||||
assert_equal(resp["KmsKeyId"], FAKE_KMS_KEY_ID)
|
||||
assert_equal(
|
||||
resp["NotebookInstanceLifecycleConfigName"], FAKE_LIFECYCLE_CONFIG_NAME
|
||||
)
|
||||
assert_equal(resp["AcceleratorTypes"], ACCELERATOR_TYPES_PARAM)
|
||||
assert_equal(resp["DefaultCodeRepository"], FAKE_DEFAULT_CODE_REPO)
|
||||
assert_equal(resp["AdditionalCodeRepositories"], FAKE_ADDL_CODE_REPOS)
|
||||
assert resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
|
||||
assert resp["NotebookInstanceName"] == NAME_PARAM
|
||||
assert resp["NotebookInstanceStatus"] == "InService"
|
||||
assert resp["Url"] == \
|
||||
"{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
|
||||
assert resp["InstanceType"] == INSTANCE_TYPE_PARAM
|
||||
assert resp["RoleArn"] == FAKE_ROLE_ARN
|
||||
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
|
||||
assert isinstance(resp["CreationTime"], datetime.datetime)
|
||||
assert resp["DirectInternetAccess"] == "Enabled"
|
||||
assert resp["VolumeSizeInGB"] == VOLUME_SIZE_IN_GB_PARAM
|
||||
# assert resp["RootAccess"] == True # ToDo: Not sure if this defaults...
|
||||
assert resp["SubnetId"] == FAKE_SUBNET_ID
|
||||
assert resp["SecurityGroups"] == FAKE_SECURITY_GROUP_IDS
|
||||
assert resp["KmsKeyId"] == FAKE_KMS_KEY_ID
|
||||
assert resp["NotebookInstanceLifecycleConfigName"] == \
|
||||
FAKE_LIFECYCLE_CONFIG_NAME
|
||||
assert resp["AcceleratorTypes"] == ACCELERATOR_TYPES_PARAM
|
||||
assert resp["DefaultCodeRepository"] == FAKE_DEFAULT_CODE_REPO
|
||||
assert resp["AdditionalCodeRepositories"] == FAKE_ADDL_CODE_REPOS
|
||||
|
||||
resp = sagemaker.list_tags(ResourceArn=resp["NotebookInstanceArn"])
|
||||
assert_equal(resp["Tags"], GENERIC_TAGS_PARAM)
|
||||
assert resp["Tags"] == GENERIC_TAGS_PARAM
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -136,14 +133,11 @@ def test_create_notebook_instance_bad_volume_size():
|
|||
"RoleArn": FAKE_ROLE_ARN,
|
||||
"VolumeSizeInGB": vol_size,
|
||||
}
|
||||
with assert_raises(ParamValidationError) as ex:
|
||||
resp = sagemaker.create_notebook_instance(**args)
|
||||
assert_equal(
|
||||
ex.exception.args[0],
|
||||
"Parameter validation failed:\nInvalid range for parameter VolumeSizeInGB, value: {}, valid range: 5-inf".format(
|
||||
vol_size
|
||||
),
|
||||
)
|
||||
with pytest.raises(ParamValidationError) as ex:
|
||||
sagemaker.create_notebook_instance(**args)
|
||||
assert \
|
||||
ex.exception.args[0] == \
|
||||
"Parameter validation failed:\nInvalid range for parameter VolumeSizeInGB, value: {}, valid range: 5-inf".format(vol_size)
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -157,14 +151,14 @@ def test_create_notebook_instance_invalid_instance_type():
|
|||
"InstanceType": instance_type,
|
||||
"RoleArn": FAKE_ROLE_ARN,
|
||||
}
|
||||
with assert_raises(ClientError) as ex:
|
||||
resp = sagemaker.create_notebook_instance(**args)
|
||||
assert_equal(ex.exception.response["Error"]["Code"], "ValidationException")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
sagemaker.create_notebook_instance(**args)
|
||||
assert ex.exception.response["Error"]["Code"] == "ValidationException"
|
||||
expected_message = "Value '{}' at 'instanceType' failed to satisfy constraint: Member must satisfy enum value set: [".format(
|
||||
instance_type
|
||||
)
|
||||
|
||||
assert_true(expected_message in ex.exception.response["Error"]["Message"])
|
||||
assert expected_message in ex.exception.response["Error"]["Message"]
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -180,51 +174,49 @@ def test_notebook_instance_lifecycle():
|
|||
"RoleArn": FAKE_ROLE_ARN,
|
||||
}
|
||||
resp = sagemaker.create_notebook_instance(**args)
|
||||
assert_true(resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker"))
|
||||
assert_true(resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"]))
|
||||
assert resp["NotebookInstanceArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
|
||||
|
||||
resp = sagemaker.describe_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
notebook_instance_arn = resp["NotebookInstanceArn"]
|
||||
|
||||
with assert_raises(ClientError) as ex:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
sagemaker.delete_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
assert_equal(ex.exception.response["Error"]["Code"], "ValidationException")
|
||||
assert ex.exception.response["Error"]["Code"] == "ValidationException"
|
||||
expected_message = "Status (InService) not in ([Stopped, Failed]). Unable to transition to (Deleting) for Notebook Instance ({})".format(
|
||||
notebook_instance_arn
|
||||
)
|
||||
assert_true(expected_message in ex.exception.response["Error"]["Message"])
|
||||
assert expected_message in ex.exception.response["Error"]["Message"]
|
||||
|
||||
sagemaker.stop_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
|
||||
resp = sagemaker.describe_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
assert_equal(resp["NotebookInstanceStatus"], "Stopped")
|
||||
assert resp["NotebookInstanceStatus"] == "Stopped"
|
||||
|
||||
sagemaker.start_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
|
||||
resp = sagemaker.describe_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
assert_equal(resp["NotebookInstanceStatus"], "InService")
|
||||
assert resp["NotebookInstanceStatus"] == "InService"
|
||||
|
||||
sagemaker.stop_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
|
||||
resp = sagemaker.describe_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
assert_equal(resp["NotebookInstanceStatus"], "Stopped")
|
||||
assert resp["NotebookInstanceStatus"] == "Stopped"
|
||||
|
||||
sagemaker.delete_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
|
||||
with assert_raises(ClientError) as ex:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
sagemaker.describe_notebook_instance(NotebookInstanceName=NAME_PARAM)
|
||||
assert_equal(ex.exception.response["Error"]["Message"], "RecordNotFound")
|
||||
assert ex.exception.response["Error"]["Message"] == "RecordNotFound"
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
def test_describe_nonexistent_model():
|
||||
sagemaker = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
resp = sagemaker.describe_model(ModelName="Nonexistent")
|
||||
assert_true(
|
||||
e.exception.response["Error"]["Message"].startswith("Could not find model")
|
||||
)
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.describe_model(ModelName="Nonexistent")
|
||||
assert e.exception.response["Error"]["Message"].startswith("Could not find model")
|
||||
|
||||
|
||||
@mock_sagemaker
|
||||
|
|
@ -237,56 +229,50 @@ def test_notebook_instance_lifecycle_config():
|
|||
resp = sagemaker.create_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name, OnCreate=on_create, OnStart=on_start
|
||||
)
|
||||
assert_true(
|
||||
resp["NotebookInstanceLifecycleConfigArn"].startswith("arn:aws:sagemaker")
|
||||
)
|
||||
assert_true(resp["NotebookInstanceLifecycleConfigArn"].endswith(name))
|
||||
assert resp["NotebookInstanceLifecycleConfigArn"].startswith("arn:aws:sagemaker")
|
||||
assert resp["NotebookInstanceLifecycleConfigArn"].endswith(name)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
resp = sagemaker.create_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
OnCreate=on_create,
|
||||
OnStart=on_start,
|
||||
)
|
||||
assert_true(
|
||||
assert \
|
||||
e.exception.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config already exists.)"
|
||||
)
|
||||
)
|
||||
|
||||
resp = sagemaker.describe_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
)
|
||||
assert_equal(resp["NotebookInstanceLifecycleConfigName"], name)
|
||||
assert_true(
|
||||
assert resp["NotebookInstanceLifecycleConfigName"] == name
|
||||
assert \
|
||||
resp["NotebookInstanceLifecycleConfigArn"].startswith("arn:aws:sagemaker")
|
||||
)
|
||||
assert_true(resp["NotebookInstanceLifecycleConfigArn"].endswith(name))
|
||||
assert_equal(resp["OnStart"], on_start)
|
||||
assert_equal(resp["OnCreate"], on_create)
|
||||
assert_true(isinstance(resp["LastModifiedTime"], datetime.datetime))
|
||||
assert_true(isinstance(resp["CreationTime"], datetime.datetime))
|
||||
assert resp["NotebookInstanceLifecycleConfigArn"].endswith(name)
|
||||
assert resp["OnStart"] == on_start
|
||||
assert resp["OnCreate"] == on_create
|
||||
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
|
||||
assert isinstance(resp["CreationTime"], datetime.datetime)
|
||||
|
||||
sagemaker.delete_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.describe_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
)
|
||||
assert_true(
|
||||
assert \
|
||||
e.exception.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config does not exist.)"
|
||||
)
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
sagemaker.delete_notebook_instance_lifecycle_config(
|
||||
NotebookInstanceLifecycleConfigName=name,
|
||||
)
|
||||
assert_true(
|
||||
assert \
|
||||
e.exception.response["Error"]["Message"].endswith(
|
||||
"Notebook Instance Lifecycle Config does not exist.)"
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import sure # noqa
|
|||
|
||||
from moto import mock_sagemaker
|
||||
from moto.sts.models import ACCOUNT_ID
|
||||
from nose.tools import assert_true, assert_equal, assert_raises, assert_regexp_matches
|
||||
|
||||
FAKE_ROLE_ARN = "arn:aws:iam::{}:role/FakeRole".format(ACCOUNT_ID)
|
||||
TEST_REGION_NAME = "us-east-1"
|
||||
|
|
@ -82,46 +81,41 @@ def test_create_training_job():
|
|||
resp["TrainingJobArn"].should.match(
|
||||
r"^arn:aws:sagemaker:.*:.*:training-job/{}$".format(training_job_name)
|
||||
)
|
||||
assert_true(
|
||||
resp["ModelArtifacts"]["S3ModelArtifacts"].startswith(
|
||||
assert resp["ModelArtifacts"]["S3ModelArtifacts"].startswith(
|
||||
params["OutputDataConfig"]["S3OutputPath"]
|
||||
)
|
||||
)
|
||||
assert_true(training_job_name in (resp["ModelArtifacts"]["S3ModelArtifacts"]))
|
||||
assert_true(
|
||||
assert training_job_name in (resp["ModelArtifacts"]["S3ModelArtifacts"])
|
||||
assert \
|
||||
resp["ModelArtifacts"]["S3ModelArtifacts"].endswith("output/model.tar.gz")
|
||||
)
|
||||
assert_equal(resp["TrainingJobStatus"], "Completed")
|
||||
assert_equal(resp["SecondaryStatus"], "Completed")
|
||||
assert_equal(resp["HyperParameters"], params["HyperParameters"])
|
||||
assert_equal(
|
||||
resp["AlgorithmSpecification"]["TrainingImage"],
|
||||
params["AlgorithmSpecification"]["TrainingImage"],
|
||||
)
|
||||
assert_equal(
|
||||
resp["AlgorithmSpecification"]["TrainingInputMode"],
|
||||
params["AlgorithmSpecification"]["TrainingInputMode"],
|
||||
)
|
||||
assert_true("MetricDefinitions" in resp["AlgorithmSpecification"])
|
||||
assert_true("Name" in resp["AlgorithmSpecification"]["MetricDefinitions"][0])
|
||||
assert_true("Regex" in resp["AlgorithmSpecification"]["MetricDefinitions"][0])
|
||||
assert_equal(resp["RoleArn"], FAKE_ROLE_ARN)
|
||||
assert_equal(resp["InputDataConfig"], params["InputDataConfig"])
|
||||
assert_equal(resp["OutputDataConfig"], params["OutputDataConfig"])
|
||||
assert_equal(resp["ResourceConfig"], params["ResourceConfig"])
|
||||
assert_equal(resp["StoppingCondition"], params["StoppingCondition"])
|
||||
assert_true(isinstance(resp["CreationTime"], datetime.datetime))
|
||||
assert_true(isinstance(resp["TrainingStartTime"], datetime.datetime))
|
||||
assert_true(isinstance(resp["TrainingEndTime"], datetime.datetime))
|
||||
assert_true(isinstance(resp["LastModifiedTime"], datetime.datetime))
|
||||
assert_true("SecondaryStatusTransitions" in resp)
|
||||
assert_true("Status" in resp["SecondaryStatusTransitions"][0])
|
||||
assert_true("StartTime" in resp["SecondaryStatusTransitions"][0])
|
||||
assert_true("EndTime" in resp["SecondaryStatusTransitions"][0])
|
||||
assert_true("StatusMessage" in resp["SecondaryStatusTransitions"][0])
|
||||
assert_true("FinalMetricDataList" in resp)
|
||||
assert_true("MetricName" in resp["FinalMetricDataList"][0])
|
||||
assert_true("Value" in resp["FinalMetricDataList"][0])
|
||||
assert_true("Timestamp" in resp["FinalMetricDataList"][0])
|
||||
assert resp["TrainingJobStatus"] == "Completed"
|
||||
assert resp["SecondaryStatus"] == "Completed"
|
||||
assert resp["HyperParameters"] == params["HyperParameters"]
|
||||
assert \
|
||||
resp["AlgorithmSpecification"]["TrainingImage"] == \
|
||||
params["AlgorithmSpecification"]["TrainingImage"]
|
||||
assert \
|
||||
resp["AlgorithmSpecification"]["TrainingInputMode"] == \
|
||||
params["AlgorithmSpecification"]["TrainingInputMode"]
|
||||
assert "MetricDefinitions" in resp["AlgorithmSpecification"]
|
||||
assert "Name" in resp["AlgorithmSpecification"]["MetricDefinitions"][0]
|
||||
assert "Regex" in resp["AlgorithmSpecification"]["MetricDefinitions"][0]
|
||||
assert resp["RoleArn"] == FAKE_ROLE_ARN
|
||||
assert resp["InputDataConfig"] == params["InputDataConfig"]
|
||||
assert resp["OutputDataConfig"] == params["OutputDataConfig"]
|
||||
assert resp["ResourceConfig"] == params["ResourceConfig"]
|
||||
assert resp["StoppingCondition"] == params["StoppingCondition"]
|
||||
assert isinstance(resp["CreationTime"], datetime.datetime)
|
||||
assert isinstance(resp["TrainingStartTime"], datetime.datetime)
|
||||
assert isinstance(resp["TrainingEndTime"], datetime.datetime)
|
||||
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
|
||||
assert "SecondaryStatusTransitions" in resp
|
||||
assert "Status" in resp["SecondaryStatusTransitions"][0]
|
||||
assert "StartTime" in resp["SecondaryStatusTransitions"][0]
|
||||
assert "EndTime" in resp["SecondaryStatusTransitions"][0]
|
||||
assert "StatusMessage" in resp["SecondaryStatusTransitions"][0]
|
||||
assert "FinalMetricDataList" in resp
|
||||
assert "MetricName" in resp["FinalMetricDataList"][0]
|
||||
assert "Value" in resp["FinalMetricDataList"][0]
|
||||
assert "Timestamp" in resp["FinalMetricDataList"][0]
|
||||
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue