Techdebt: Replace sure with regular asserts in DataBrew (#6459)
This commit is contained in:
parent
2b0dd93c83
commit
3e11578a72
@ -99,8 +99,8 @@ def test_dataset_list_when_empty():
|
||||
client = _create_databrew_client()
|
||||
|
||||
response = client.list_datasets()
|
||||
response.should.have.key("Datasets")
|
||||
response["Datasets"].should.have.length_of(0)
|
||||
assert "Datasets" in response
|
||||
assert len(response["Datasets"]) == 0
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -109,9 +109,9 @@ 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")
|
||||
assert len(response["Datasets"]) == 2
|
||||
assert "ResourceArn" in response["Datasets"][0]
|
||||
assert "NextToken" in response
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -120,7 +120,7 @@ def test_list_datasets_from_next_token():
|
||||
_create_test_datasets(client, 10)
|
||||
first_response = client.list_datasets(MaxResults=3)
|
||||
response = client.list_datasets(NextToken=first_response["NextToken"])
|
||||
response["Datasets"].should.have.length_of(7)
|
||||
assert len(response["Datasets"]) == 7
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -128,7 +128,7 @@ def test_list_datasets_with_max_results_greater_than_actual_results():
|
||||
client = _create_databrew_client()
|
||||
_create_test_datasets(client, 4)
|
||||
response = client.list_datasets(MaxResults=10)
|
||||
response["Datasets"].should.have.length_of(4)
|
||||
assert len(response["Datasets"]) == 4
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -138,16 +138,17 @@ def test_describe_dataset():
|
||||
# region basic test
|
||||
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']}"
|
||||
assert dataset["Name"] == response["Name"]
|
||||
assert (
|
||||
dataset["ResourceArn"]
|
||||
== f"arn:aws:databrew:us-west-1:{ACCOUNT_ID}:dataset/{response['Name']}"
|
||||
)
|
||||
# endregion
|
||||
|
||||
# region JSON test
|
||||
response = _create_test_dataset(client, dataset_format="CSV")
|
||||
dataset = client.describe_dataset(Name=response["Name"])
|
||||
dataset["Format"].should.equal("CSV")
|
||||
assert dataset["Format"] == "CSV"
|
||||
# endregion
|
||||
|
||||
|
||||
@ -158,8 +159,8 @@ def test_describe_dataset_that_does_not_exist():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_dataset(Name="DoseNotExist")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("One or more resources can't be found.")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "One or more resources can't be found."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -171,8 +172,8 @@ def test_create_dataset_that_already_exists():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_dataset(client, dataset_name=response["Name"])
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("AlreadyExistsException")
|
||||
err["Message"].should.equal(f"{response['Name']} already exists.")
|
||||
assert err["Code"] == "AlreadyExistsException"
|
||||
assert err["Message"] == f"{response['Name']} already exists."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -182,7 +183,7 @@ def test_delete_dataset():
|
||||
|
||||
# Check dataset exists
|
||||
dataset = client.describe_dataset(Name=response["Name"])
|
||||
dataset["Name"].should.equal(response["Name"])
|
||||
assert dataset["Name"] == response["Name"]
|
||||
|
||||
# Delete the dataset
|
||||
client.delete_dataset(Name=response["Name"])
|
||||
@ -192,15 +193,15 @@ def test_delete_dataset():
|
||||
client.describe_dataset(Name=response["Name"])
|
||||
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("One or more resources can't be found.")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "One or more resources can't be found."
|
||||
|
||||
# Check that a dataset that does not exist errors
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_dataset(Name=response["Name"])
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("One or more resources can't be found.")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "One or more resources can't be found."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -231,14 +232,15 @@ def test_update_dataset():
|
||||
},
|
||||
},
|
||||
)
|
||||
dataset["Name"].should.equal(response["Name"])
|
||||
assert dataset["Name"] == response["Name"]
|
||||
|
||||
# Describe the dataset and check the changes
|
||||
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']}"
|
||||
assert dataset["Name"] == response["Name"]
|
||||
assert dataset["Format"] == "TEST"
|
||||
assert (
|
||||
dataset["ResourceArn"]
|
||||
== f"arn:aws:databrew:us-west-1:{ACCOUNT_ID}:dataset/{response['Name']}"
|
||||
)
|
||||
|
||||
|
||||
@ -272,5 +274,5 @@ def test_update_dataset_that_does_not_exist():
|
||||
)
|
||||
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("One or more resources can't be found.")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "One or more resources can't be found."
|
||||
|
@ -78,9 +78,9 @@ def test_create_profile_job_that_already_exists():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_profile_job(client, job_name=response["Name"])
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ConflictException")
|
||||
err["Message"].should.equal(f"The job {job_name} profile job already exists.")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(409)
|
||||
assert err["Code"] == "ConflictException"
|
||||
assert err["Message"] == f"The job {job_name} profile job already exists."
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -92,9 +92,9 @@ def test_create_recipe_job_that_already_exists():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_recipe_job(client, job_name=response["Name"])
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ConflictException")
|
||||
err["Message"].should.equal(f"The job {job_name} recipe job already exists.")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(409)
|
||||
assert err["Code"] == "ConflictException"
|
||||
assert err["Message"] == f"The job {job_name} recipe job already exists."
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -104,12 +104,12 @@ def test_create_recipe_job_with_invalid_encryption_mode():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_recipe_job(client, encryption_mode="INVALID")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
"1 validation error detected: Value 'INVALID' at 'encryptionMode' failed to satisfy constraint: "
|
||||
"Member must satisfy enum value set: [SSE-S3, SSE-KMS]"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== "1 validation error detected: Value 'INVALID' at 'encryptionMode' failed to satisfy constraint: Member must satisfy enum value set: [SSE-S3, SSE-KMS]"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -119,12 +119,12 @@ def test_create_recipe_job_with_invalid_log_subscription_value():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_recipe_job(client, log_subscription="INVALID")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
"1 validation error detected: Value 'INVALID' at 'logSubscription' failed to satisfy constraint: "
|
||||
"Member must satisfy enum value set: [ENABLE, DISABLE]"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== "1 validation error detected: Value 'INVALID' at 'logSubscription' failed to satisfy constraint: Member must satisfy enum value set: [ENABLE, DISABLE]"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -136,9 +136,9 @@ def test_create_recipe_job_with_same_name_as_profile_job():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_recipe_job(client, job_name=response["Name"])
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ConflictException")
|
||||
err["Message"].should.equal(f"The job {job_name} profile job already exists.")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(409)
|
||||
assert err["Code"] == "ConflictException"
|
||||
assert err["Message"] == f"The job {job_name} profile job already exists."
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -148,12 +148,12 @@ def test_describe_recipe_job():
|
||||
response = _create_test_recipe_job(client)
|
||||
job_name = response["Name"]
|
||||
job = client.describe_job(Name=job_name)
|
||||
job.should.have.key("Name").equal(response["Name"])
|
||||
job.should.have.key("Type").equal("RECIPE")
|
||||
job.should.have.key("ResourceArn").equal(
|
||||
f"arn:aws:databrew:us-west-1:{ACCOUNT_ID}:job/{job_name}"
|
||||
assert job["Name"] == response["Name"]
|
||||
assert job["Type"] == "RECIPE"
|
||||
assert (
|
||||
job["ResourceArn"] == f"arn:aws:databrew:us-west-1:{ACCOUNT_ID}:job/{job_name}"
|
||||
)
|
||||
job["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert job["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -163,9 +163,9 @@ def test_describe_job_that_does_not_exist():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_job(Name="DoesNotExist")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("Job DoesNotExist wasn't found.")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "Job DoesNotExist wasn't found."
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -175,12 +175,12 @@ def test_describe_job_with_long_name():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_job(Name=name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: "
|
||||
f"Member must have length less than or equal to 240"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: Member must have length less than or equal to 240"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -195,13 +195,13 @@ def test_update_profile_job():
|
||||
update_response = client.update_profile_job(
|
||||
Name=job_name, RoleArn="a" * 20, OutputLocation={"Bucket": "b" * 20}
|
||||
)
|
||||
update_response.should.have.key("Name").equals(job_name)
|
||||
update_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert update_response["Name"] == job_name
|
||||
assert update_response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
# Describe the job to check that RoleArn was updated
|
||||
job = client.describe_job(Name=job_name)
|
||||
job.should.have.key("Name").equal(response["Name"])
|
||||
job.should.have.key("RoleArn").equal("a" * 20)
|
||||
assert job["Name"] == response["Name"]
|
||||
assert job["RoleArn"] == "a" * 20
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -214,13 +214,13 @@ def test_update_recipe_job():
|
||||
|
||||
# Update the job by changing RoleArn
|
||||
update_response = client.update_recipe_job(Name=job_name, RoleArn="a" * 20)
|
||||
update_response.should.have.key("Name").equals(job_name)
|
||||
update_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert update_response["Name"] == job_name
|
||||
assert update_response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
# Describe the job to check that RoleArn was updated
|
||||
job = client.describe_job(Name=job_name)
|
||||
job.should.have.key("Name").equal(response["Name"])
|
||||
job.should.have.key("RoleArn").equal("a" * 20)
|
||||
assert job["Name"] == response["Name"]
|
||||
assert job["RoleArn"] == "a" * 20
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -232,9 +232,9 @@ def test_update_profile_job_does_not_exist():
|
||||
Name="DoesNotExist", RoleArn="a" * 20, OutputLocation={"Bucket": "b" * 20}
|
||||
)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("The job DoesNotExist wasn't found")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "The job DoesNotExist wasn't found"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -244,9 +244,9 @@ def test_update_recipe_job_does_not_exist():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.update_recipe_job(Name="DoesNotExist", RoleArn="a" * 20)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("The job DoesNotExist wasn't found")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "The job DoesNotExist wasn't found"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -259,16 +259,16 @@ def test_delete_job():
|
||||
|
||||
# Delete the job
|
||||
response = client.delete_job(Name=job_name)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
response["Name"].should.equal(job_name)
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
assert response["Name"] == job_name
|
||||
|
||||
# Check the job does not exist anymore
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_job(Name=job_name)
|
||||
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal(f"Job {job_name} wasn't found.")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == f"Job {job_name} wasn't found."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -278,11 +278,11 @@ def test_delete_job_does_not_exist():
|
||||
# Delete the job
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_job(Name="DoesNotExist")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal("The job DoesNotExist wasn't found.")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == "The job DoesNotExist wasn't found."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -292,12 +292,12 @@ def test_delete_job_with_long_name():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_job(Name=name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: "
|
||||
f"Member must have length less than or equal to 240"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: Member must have length less than or equal to 240"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -305,9 +305,8 @@ def test_job_list_when_empty():
|
||||
client = _create_databrew_client()
|
||||
|
||||
response = client.list_jobs()
|
||||
response.should.have.key("Jobs")
|
||||
response["Jobs"].should.have.length_of(0)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 0
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -316,9 +315,9 @@ def test_list_jobs_with_max_results():
|
||||
|
||||
_create_test_recipe_jobs(client, 4)
|
||||
response = client.list_jobs(MaxResults=2)
|
||||
response["Jobs"].should.have.length_of(2)
|
||||
response.should.have.key("NextToken")
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 2
|
||||
assert "NextToken" in response
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -327,8 +326,8 @@ def test_list_jobs_from_next_token():
|
||||
_create_test_recipe_jobs(client, 10)
|
||||
first_response = client.list_jobs(MaxResults=3)
|
||||
response = client.list_jobs(NextToken=first_response["NextToken"])
|
||||
response["Jobs"].should.have.length_of(7)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 7
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -336,8 +335,8 @@ def test_list_jobs_with_max_results_greater_than_actual_results():
|
||||
client = _create_databrew_client()
|
||||
_create_test_recipe_jobs(client, 4)
|
||||
response = client.list_jobs(MaxResults=10)
|
||||
response["Jobs"].should.have.length_of(4)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 4
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -347,8 +346,8 @@ def test_list_jobs_recipe_and_profile():
|
||||
_create_test_recipe_jobs(client, 4)
|
||||
_create_test_profile_jobs(client, 2)
|
||||
response = client.list_jobs()
|
||||
response["Jobs"].should.have.length_of(6)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 6
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -361,8 +360,8 @@ def test_list_jobs_dataset_name_filter():
|
||||
_create_test_profile_jobs(client, 1)
|
||||
|
||||
response = client.list_jobs(DatasetName="TEST")
|
||||
response["Jobs"].should.have.length_of(7)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 7
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -374,8 +373,8 @@ def test_list_jobs_project_name_filter():
|
||||
_create_test_profile_jobs(client, 1)
|
||||
|
||||
response = client.list_jobs(ProjectName="TEST_PROJECT")
|
||||
response["Jobs"].should.have.length_of(3)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 3
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -391,5 +390,5 @@ def test_list_jobs_dataset_name_and_project_name_filter():
|
||||
_create_test_profile_jobs(client, 1)
|
||||
|
||||
response = client.list_jobs(DatasetName="TEST", ProjectName="TEST_PROJECT")
|
||||
response["Jobs"].should.have.length_of(10)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert len(response["Jobs"]) == 10
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
@ -55,8 +55,8 @@ def test_recipe_list_when_empty():
|
||||
client = _create_databrew_client()
|
||||
|
||||
response = client.list_recipes()
|
||||
response.should.have.key("Recipes")
|
||||
response["Recipes"].should.have.length_of(0)
|
||||
assert "Recipes" in response
|
||||
assert len(response["Recipes"]) == 0
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -67,14 +67,14 @@ def test_recipe_list_with_invalid_version():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.list_recipes(RecipeVersion=recipe_version)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"Invalid version {recipe_version}. "
|
||||
"Valid versions are LATEST_PUBLISHED and LATEST_WORKING."
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== f"Invalid version {recipe_version}. Valid versions are LATEST_PUBLISHED and LATEST_WORKING."
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
assert err["Code"] == "ValidationException"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -83,8 +83,8 @@ def test_list_recipes_with_max_results():
|
||||
|
||||
_create_test_recipes(client, 4)
|
||||
response = client.list_recipes(MaxResults=2, RecipeVersion="LATEST_WORKING")
|
||||
response["Recipes"].should.have.length_of(2)
|
||||
response.should.have.key("NextToken")
|
||||
assert len(response["Recipes"]) == 2
|
||||
assert "NextToken" in response
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -95,7 +95,7 @@ def test_list_recipes_from_next_token():
|
||||
response = client.list_recipes(
|
||||
NextToken=first_response["NextToken"], RecipeVersion="LATEST_WORKING"
|
||||
)
|
||||
response["Recipes"].should.have.length_of(7)
|
||||
assert len(response["Recipes"]) == 7
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -103,7 +103,7 @@ def test_list_recipes_with_max_results_greater_than_actual_results():
|
||||
client = _create_databrew_client()
|
||||
_create_test_recipes(client, 4)
|
||||
response = client.list_recipes(MaxResults=10, RecipeVersion="LATEST_WORKING")
|
||||
response["Recipes"].should.have.length_of(4)
|
||||
assert len(response["Recipes"]) == 4
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -111,7 +111,7 @@ def test_list_recipe_versions_no_recipe():
|
||||
client = _create_databrew_client()
|
||||
recipe_name = "NotExist"
|
||||
response = client.list_recipe_versions(Name=recipe_name)
|
||||
response["Recipes"].should.have.length_of(0)
|
||||
assert len(response["Recipes"]) == 0
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -120,7 +120,7 @@ def test_list_recipe_versions_none_published():
|
||||
response = _create_test_recipe(client)
|
||||
recipe_name = response["Name"]
|
||||
response = client.list_recipe_versions(Name=recipe_name)
|
||||
response["Recipes"].should.have.length_of(0)
|
||||
assert len(response["Recipes"]) == 0
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -130,8 +130,8 @@ def test_list_recipe_versions_one_published():
|
||||
recipe_name = response["Name"]
|
||||
client.publish_recipe(Name=recipe_name)
|
||||
response = client.list_recipe_versions(Name=recipe_name)
|
||||
response["Recipes"].should.have.length_of(1)
|
||||
response["Recipes"][0]["RecipeVersion"].should.equal("1.0")
|
||||
assert len(response["Recipes"]) == 1
|
||||
assert response["Recipes"][0]["RecipeVersion"] == "1.0"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -142,9 +142,9 @@ def test_list_recipe_versions_two_published():
|
||||
client.publish_recipe(Name=recipe_name)
|
||||
client.publish_recipe(Name=recipe_name)
|
||||
response = client.list_recipe_versions(Name=recipe_name)
|
||||
response["Recipes"].should.have.length_of(2)
|
||||
response["Recipes"][0]["RecipeVersion"].should.equal("1.0")
|
||||
response["Recipes"][1]["RecipeVersion"].should.equal("2.0")
|
||||
assert len(response["Recipes"]) == 2
|
||||
assert response["Recipes"][0]["RecipeVersion"] == "1.0"
|
||||
assert response["Recipes"][1]["RecipeVersion"] == "2.0"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -156,9 +156,9 @@ def test_describe_recipe_latest_working():
|
||||
Name=response["Name"], RecipeVersion="LATEST_WORKING"
|
||||
)
|
||||
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
recipe["Steps"].should.have.length_of(1)
|
||||
recipe["RecipeVersion"].should.equal("0.1")
|
||||
assert recipe["Name"] == response["Name"]
|
||||
assert len(recipe["Steps"]) == 1
|
||||
assert recipe["RecipeVersion"] == "0.1"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -168,9 +168,9 @@ def test_describe_recipe_with_version():
|
||||
|
||||
recipe = client.describe_recipe(Name=response["Name"], RecipeVersion="0.1")
|
||||
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
recipe["Steps"].should.have.length_of(1)
|
||||
recipe["RecipeVersion"].should.equal("0.1")
|
||||
assert recipe["Name"] == response["Name"]
|
||||
assert len(recipe["Steps"]) == 1
|
||||
assert recipe["RecipeVersion"] == "0.1"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -183,9 +183,9 @@ def test_describe_recipe_latest_published():
|
||||
Name=response["Name"], RecipeVersion="LATEST_PUBLISHED"
|
||||
)
|
||||
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
recipe["Steps"].should.have.length_of(1)
|
||||
recipe["RecipeVersion"].should.equal("1.0")
|
||||
assert recipe["Name"] == response["Name"]
|
||||
assert len(recipe["Steps"]) == 1
|
||||
assert recipe["RecipeVersion"] == "1.0"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -196,9 +196,9 @@ def test_describe_recipe_implicit_latest_published():
|
||||
client.publish_recipe(Name=response["Name"])
|
||||
recipe = client.describe_recipe(Name=response["Name"])
|
||||
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
recipe["Steps"].should.have.length_of(1)
|
||||
recipe["RecipeVersion"].should.equal("1.0")
|
||||
assert recipe["Name"] == response["Name"]
|
||||
assert len(recipe["Steps"]) == 1
|
||||
assert recipe["RecipeVersion"] == "1.0"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -208,11 +208,12 @@ def test_describe_recipe_that_does_not_exist():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_recipe(Name="DoseNotExist")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal(
|
||||
"The recipe DoseNotExist for version LATEST_PUBLISHED wasn't found."
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== "The recipe DoseNotExist for version LATEST_PUBLISHED wasn't found."
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -222,12 +223,12 @@ def test_describe_recipe_with_long_name():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_recipe(Name=name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: "
|
||||
f"Member must have length less than or equal to 255"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: Member must have length less than or equal to 255"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -237,12 +238,12 @@ def test_describe_recipe_with_long_version():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_recipe(Name="AnyName", RecipeVersion=version)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"1 validation error detected: Value '{version}' at 'recipeVersion' failed to satisfy constraint: "
|
||||
f"Member must have length less than or equal to 16"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== f"1 validation error detected: Value '{version}' at 'recipeVersion' failed to satisfy constraint: Member must have length less than or equal to 16"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -253,9 +254,9 @@ def test_describe_recipe_with_invalid_version():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_recipe(Name=name, RecipeVersion=version)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(f"Recipe {name} version {version} isn't valid.")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert err["Message"] == f"Recipe {name} version {version} isn't valid."
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -289,15 +290,15 @@ def test_update_recipe():
|
||||
],
|
||||
)
|
||||
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
assert recipe["Name"] == response["Name"]
|
||||
|
||||
# Describe the recipe and check the changes
|
||||
recipe = client.describe_recipe(
|
||||
Name=response["Name"], RecipeVersion="LATEST_WORKING"
|
||||
)
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
recipe["Steps"].should.have.length_of(1)
|
||||
recipe["Steps"][0]["Action"]["Parameters"]["removeCustomValue"].should.equal("true")
|
||||
assert recipe["Name"] == response["Name"]
|
||||
assert len(recipe["Steps"]) == 1
|
||||
assert recipe["Steps"][0]["Action"]["Parameters"]["removeCustomValue"] == "true"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -310,14 +311,14 @@ def test_update_recipe_description():
|
||||
Name=response["Name"], Steps=[], Description=description
|
||||
)
|
||||
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
assert recipe["Name"] == response["Name"]
|
||||
|
||||
# Describe the recipe and check the changes
|
||||
recipe = client.describe_recipe(
|
||||
Name=response["Name"], RecipeVersion="LATEST_WORKING"
|
||||
)
|
||||
recipe["Name"].should.equal(response["Name"])
|
||||
recipe["Description"].should.equal(description)
|
||||
assert recipe["Name"] == response["Name"]
|
||||
assert recipe["Description"] == description
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -328,9 +329,9 @@ def test_update_recipe_invalid():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.update_recipe(Name=recipe_name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal(f"The recipe {recipe_name} wasn't found")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == f"The recipe {recipe_name} wasn't found"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -342,9 +343,9 @@ def test_create_recipe_that_already_exists():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_recipe(client, recipe_name=response["Name"])
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ConflictException")
|
||||
err["Message"].should.equal(f"The recipe {recipe_name} already exists")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(409)
|
||||
assert err["Code"] == "ConflictException"
|
||||
assert err["Message"] == f"The recipe {recipe_name} already exists"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -358,29 +359,29 @@ def test_publish_recipe():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
recipe = client.describe_recipe(Name=recipe_name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
|
||||
dt_before_publish = datetime.now().astimezone()
|
||||
|
||||
# Publish the recipe
|
||||
publish_response = client.publish_recipe(Name=recipe_name, Description="1st desc")
|
||||
publish_response["Name"].should.equal(recipe_name)
|
||||
assert publish_response["Name"] == recipe_name
|
||||
|
||||
# Recipe is now published, so check we can retrieve the published version
|
||||
recipe = client.describe_recipe(Name=recipe_name)
|
||||
recipe["Description"].should.equal("1st desc")
|
||||
recipe["RecipeVersion"].should.equal("1.0")
|
||||
recipe["PublishedDate"].should.be.greater_than(dt_before_publish)
|
||||
assert recipe["Description"] == "1st desc"
|
||||
assert recipe["RecipeVersion"] == "1.0"
|
||||
assert recipe["PublishedDate"] > dt_before_publish
|
||||
first_published_date = recipe["PublishedDate"]
|
||||
|
||||
# Publish the recipe a 2nd time
|
||||
publish_response = client.publish_recipe(Name=recipe_name, Description="2nd desc")
|
||||
publish_response["Name"].should.equal(recipe_name)
|
||||
assert publish_response["Name"] == recipe_name
|
||||
|
||||
recipe = client.describe_recipe(Name=recipe_name)
|
||||
recipe["Description"].should.equal("2nd desc")
|
||||
recipe["RecipeVersion"].should.equal("2.0")
|
||||
recipe["PublishedDate"].should.be.greater_than(first_published_date)
|
||||
assert recipe["Description"] == "2nd desc"
|
||||
assert recipe["RecipeVersion"] == "2.0"
|
||||
assert recipe["PublishedDate"] > first_published_date
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -389,8 +390,8 @@ def test_publish_recipe_that_does_not_exist():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.publish_recipe(Name="DoesNotExist")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -400,14 +401,14 @@ def test_publish_long_recipe_name():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.publish_recipe(Name=name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: "
|
||||
f"Member must have length less than or equal to 255"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== f"1 validation error detected: Value '{name}' at 'name' failed to satisfy constraint: Member must have length less than or equal to 255"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
assert err["Code"] == "ValidationException"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -419,8 +420,8 @@ def test_delete_recipe_version():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_recipe(Name=recipe_name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -433,10 +434,10 @@ def test_delete_recipe_version_published():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_recipe(Name=recipe_name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
recipe = client.describe_recipe(Name=recipe_name, RecipeVersion="1.1")
|
||||
recipe["RecipeVersion"].should.equal("1.1")
|
||||
assert recipe["RecipeVersion"] == "1.1"
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -448,11 +449,11 @@ def test_delete_recipe_version_latest_working_after_publish():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_recipe_version(Name=recipe_name, RecipeVersion="LATEST_WORKING")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
"Recipe version LATEST_WORKING is not allowed to be deleted"
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"] == "Recipe version LATEST_WORKING is not allowed to be deleted"
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -464,9 +465,9 @@ def test_delete_recipe_version_latest_working_numeric_after_publish():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_recipe_version(Name=recipe_name, RecipeVersion="1.1")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal("Recipe version 1.1 is not allowed to be deleted")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert err["Message"] == "Recipe version 1.1 is not allowed to be deleted"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -479,11 +480,11 @@ def test_delete_recipe_version_invalid_version_string():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_recipe_version(Name=recipe_name, RecipeVersion=recipe_version)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"Recipe {recipe_name} version {recipe_version} is invalid."
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"] == f"Recipe {recipe_name} version {recipe_version} is invalid."
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -496,11 +497,11 @@ def test_delete_recipe_version_invalid_version_length():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_recipe_version(Name=recipe_name, RecipeVersion=recipe_version)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ValidationException")
|
||||
err["Message"].should.equal(
|
||||
f"Recipe {recipe_name} version {recipe_version} is invalid."
|
||||
assert err["Code"] == "ValidationException"
|
||||
assert (
|
||||
err["Message"] == f"Recipe {recipe_name} version {recipe_version} is invalid."
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -510,9 +511,9 @@ def test_delete_recipe_version_unknown_recipe():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_recipe_version(Name=recipe_name, RecipeVersion="1.1")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal(f"The recipe {recipe_name} wasn't found")
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert err["Message"] == f"The recipe {recipe_name} wasn't found"
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -524,8 +525,9 @@ def test_delete_recipe_version_unknown_version():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_recipe_version(Name=recipe_name, RecipeVersion=recipe_version)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.equal(
|
||||
f"The recipe {recipe_name} version {recipe_version} wasn't found."
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
assert (
|
||||
err["Message"]
|
||||
== f"The recipe {recipe_name} version {recipe_version} wasn't found."
|
||||
)
|
||||
exc.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(404)
|
||||
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
|
||||
|
@ -8,8 +8,7 @@ from moto import mock_databrew
|
||||
|
||||
|
||||
def _create_databrew_client():
|
||||
client = boto3.client("databrew", region_name="us-west-1")
|
||||
return client
|
||||
return boto3.client("databrew", region_name="us-west-1")
|
||||
|
||||
|
||||
def _create_test_ruleset(client, tags=None, ruleset_name=None):
|
||||
@ -46,8 +45,8 @@ def test_ruleset_list_when_empty():
|
||||
client = _create_databrew_client()
|
||||
|
||||
response = client.list_rulesets()
|
||||
response.should.have.key("Rulesets")
|
||||
response["Rulesets"].should.have.length_of(0)
|
||||
assert "Rulesets" in response
|
||||
assert len(response["Rulesets"]) == 0
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -56,8 +55,8 @@ def test_list_ruleset_with_max_results():
|
||||
|
||||
_create_test_rulesets(client, 4)
|
||||
response = client.list_rulesets(MaxResults=2)
|
||||
response["Rulesets"].should.have.length_of(2)
|
||||
response.should.have.key("NextToken")
|
||||
assert len(response["Rulesets"]) == 2
|
||||
assert "NextToken" in response
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -66,7 +65,7 @@ def test_list_rulesets_from_next_token():
|
||||
_create_test_rulesets(client, 10)
|
||||
first_response = client.list_rulesets(MaxResults=3)
|
||||
response = client.list_rulesets(NextToken=first_response["NextToken"])
|
||||
response["Rulesets"].should.have.length_of(7)
|
||||
assert len(response["Rulesets"]) == 7
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -74,7 +73,7 @@ def test_list_rulesets_with_max_results_greater_than_actual_results():
|
||||
client = _create_databrew_client()
|
||||
_create_test_rulesets(client, 4)
|
||||
response = client.list_rulesets(MaxResults=10)
|
||||
response["Rulesets"].should.have.length_of(4)
|
||||
assert len(response["Rulesets"]) == 4
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -84,9 +83,9 @@ def test_describe_ruleset():
|
||||
|
||||
ruleset = client.describe_ruleset(Name=response["Name"])
|
||||
|
||||
ruleset["Name"].should.equal(response["Name"])
|
||||
ruleset["Rules"].should.have.length_of(1)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
assert ruleset["Name"] == response["Name"]
|
||||
assert len(ruleset["Rules"]) == 1
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -96,8 +95,8 @@ def test_describe_ruleset_that_does_not_exist():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_ruleset(Name="DoseNotExist")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("EntityNotFoundException")
|
||||
err["Message"].should.equal("Ruleset DoseNotExist not found.")
|
||||
assert err["Code"] == "EntityNotFoundException"
|
||||
assert err["Message"] == "Ruleset DoseNotExist not found."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -109,8 +108,8 @@ def test_create_ruleset_that_already_exists():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
_create_test_ruleset(client, ruleset_name=response["Name"])
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("AlreadyExistsException")
|
||||
err["Message"].should.equal("Ruleset already exists.")
|
||||
assert err["Code"] == "AlreadyExistsException"
|
||||
assert err["Message"] == "Ruleset already exists."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -121,27 +120,27 @@ def test_delete_ruleset():
|
||||
|
||||
# Check ruleset exists
|
||||
ruleset = client.describe_ruleset(Name=ruleset_name)
|
||||
ruleset["Name"].should.equal(response["Name"])
|
||||
assert ruleset["Name"] == response["Name"]
|
||||
|
||||
# Delete the ruleset
|
||||
response = client.delete_ruleset(Name=ruleset_name)
|
||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||
response["Name"].should.equal(ruleset_name)
|
||||
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||
assert response["Name"] == ruleset_name
|
||||
|
||||
# Check it does not exist anymore
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.describe_ruleset(Name=ruleset_name)
|
||||
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("EntityNotFoundException")
|
||||
err["Message"].should.equal(f"Ruleset {ruleset_name} not found.")
|
||||
assert err["Code"] == "EntityNotFoundException"
|
||||
assert err["Message"] == f"Ruleset {ruleset_name} not found."
|
||||
|
||||
# Check that a ruleset that does not exist errors
|
||||
with pytest.raises(ClientError) as exc:
|
||||
client.delete_ruleset(Name=ruleset_name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("EntityNotFoundException")
|
||||
err["Message"].should.equal(f"Ruleset {ruleset_name} not found.")
|
||||
assert err["Code"] == "EntityNotFoundException"
|
||||
assert err["Message"] == f"Ruleset {ruleset_name} not found."
|
||||
|
||||
|
||||
@mock_databrew
|
||||
@ -166,10 +165,10 @@ def test_update_ruleset():
|
||||
}
|
||||
],
|
||||
)
|
||||
ruleset["Name"].should.equal(response["Name"])
|
||||
assert ruleset["Name"] == response["Name"]
|
||||
|
||||
# Describe the ruleset and check the changes
|
||||
ruleset = client.describe_ruleset(Name=response["Name"])
|
||||
ruleset["Name"].should.equal(response["Name"])
|
||||
ruleset["Rules"].should.have.length_of(1)
|
||||
ruleset["Rules"][0]["SubstitutionMap"][":val1"].should.equal("10")
|
||||
assert ruleset["Name"] == response["Name"]
|
||||
assert len(ruleset["Rules"]) == 1
|
||||
assert ruleset["Rules"][0]["SubstitutionMap"][":val1"] == "10"
|
||||
|
Loading…
Reference in New Issue
Block a user