Techdebt: Replace sure with regular assertions in MediaStore (#6653)
This commit is contained in:
parent
546dbf7f68
commit
82363e49e9
@ -1,6 +1,5 @@
|
|||||||
import boto3
|
import boto3
|
||||||
import pytest
|
import pytest
|
||||||
import sure # noqa # pylint: disable=unused-import
|
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
|
|
||||||
from moto import mock_mediastore
|
from moto import mock_mediastore
|
||||||
@ -14,43 +13,40 @@ def test_create_container_succeeds():
|
|||||||
response = client.create_container(
|
response = client.create_container(
|
||||||
ContainerName="Awesome container!", Tags=[{"Key": "customer"}]
|
ContainerName="Awesome container!", Tags=[{"Key": "customer"}]
|
||||||
)
|
)
|
||||||
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
|
|
||||||
container = response["Container"]
|
container = response["Container"]
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
assert container["ARN"] == f"arn:aws:mediastore:container:{container['Name']}"
|
||||||
container["ARN"].should.equal(f"arn:aws:mediastore:container:{container['Name']}")
|
assert container["Name"] == "Awesome container!"
|
||||||
container["Name"].should.equal("Awesome container!")
|
assert container["Status"] == "CREATING"
|
||||||
container["Status"].should.equal("CREATING")
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_describe_container_succeeds():
|
def test_describe_container_succeeds():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
create_response = client.create_container(
|
name = "Awesome container!"
|
||||||
ContainerName="Awesome container!", Tags=[{"Key": "customer"}]
|
client.create_container(ContainerName=name, Tags=[{"Key": "customer"}])
|
||||||
)
|
|
||||||
container_name = create_response["Container"]["Name"]
|
response = client.describe_container(ContainerName=name)
|
||||||
response = client.describe_container(ContainerName=container_name)
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
|
||||||
container = response["Container"]
|
container = response["Container"]
|
||||||
container["ARN"].should.equal(f"arn:aws:mediastore:container:{container_name}")
|
assert container["ARN"] == f"arn:aws:mediastore:container:{name}"
|
||||||
container["Name"].should.equal("Awesome container!")
|
assert container["Name"] == name
|
||||||
container["Status"].should.equal("ACTIVE")
|
assert container["Status"] == "ACTIVE"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_list_containers_succeeds():
|
def test_list_containers_succeeds():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
client.create_container(
|
name = "Awesome container!"
|
||||||
ContainerName="Awesome container!", Tags=[{"Key": "customer"}]
|
client.create_container(ContainerName=name, Tags=[{"Key": "customer"}])
|
||||||
)
|
containers = client.list_containers()["Containers"]
|
||||||
list_response = client.list_containers(NextToken="next-token", MaxResults=123)
|
assert len(containers) == 1
|
||||||
containers_list = list_response["Containers"]
|
|
||||||
len(containers_list).should.equal(1)
|
client.create_container(ContainerName=f"{name}2", Tags=[{"Key": "customer"}])
|
||||||
client.create_container(
|
containers = client.list_containers()["Containers"]
|
||||||
ContainerName="Awesome container2!", Tags=[{"Key": "customer"}]
|
assert len(containers) == 2
|
||||||
)
|
|
||||||
list_response = client.list_containers(NextToken="next-token", MaxResults=123)
|
|
||||||
containers_list = list_response["Containers"]
|
|
||||||
len(containers_list).should.equal(2)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -58,32 +54,27 @@ def test_describe_container_raises_error_if_container_does_not_exist():
|
|||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.describe_container(ContainerName="container-name")
|
client.describe_container(ContainerName="container-name")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_put_lifecycle_policy_succeeds():
|
def test_put_lifecycle_policy_succeeds():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
container_response = client.create_container(
|
name = "container-name"
|
||||||
ContainerName="container-name", Tags=[{"Key": "customer"}]
|
client.create_container(ContainerName=name, Tags=[{"Key": "customer"}])
|
||||||
)
|
|
||||||
container = container_response["Container"]
|
client.put_lifecycle_policy(ContainerName=name, LifecyclePolicy="lifecycle-policy")
|
||||||
client.put_lifecycle_policy(
|
response = client.get_lifecycle_policy(ContainerName=name)
|
||||||
ContainerName=container["Name"], LifecyclePolicy="lifecycle-policy"
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
)
|
assert response["LifecyclePolicy"] == "lifecycle-policy"
|
||||||
response = client.get_lifecycle_policy(ContainerName=container["Name"])
|
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
|
||||||
response["LifecyclePolicy"].should.equal("lifecycle-policy")
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_put_lifecycle_policy_raises_error_if_container_does_not_exist():
|
def test_put_lifecycle_policy_raises_error_if_container_does_not_exist():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.put_lifecycle_policy(
|
client.put_lifecycle_policy(ContainerName="name", LifecyclePolicy="policy")
|
||||||
ContainerName="container-name", LifecyclePolicy="lifecycle-policy"
|
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
|
||||||
)
|
|
||||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -91,7 +82,7 @@ def test_get_lifecycle_policy_raises_error_if_container_does_not_exist():
|
|||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.get_lifecycle_policy(ContainerName="container-name")
|
client.get_lifecycle_policy(ContainerName="container-name")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -100,32 +91,27 @@ def test_get_lifecycle_policy_raises_error_if_container_does_not_have_lifecycle_
|
|||||||
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
|
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.get_lifecycle_policy(ContainerName="container-name")
|
client.get_lifecycle_policy(ContainerName="container-name")
|
||||||
ex.value.response["Error"]["Code"].should.equal("PolicyNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "PolicyNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_put_container_policy_succeeds():
|
def test_put_container_policy_succeeds():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
container_response = client.create_container(
|
name = "container-name"
|
||||||
ContainerName="container-name", Tags=[{"Key": "customer"}]
|
client.create_container(ContainerName=name)
|
||||||
)
|
|
||||||
container = container_response["Container"]
|
client.put_container_policy(ContainerName=name, Policy="container-policy")
|
||||||
response = client.put_container_policy(
|
response = client.get_container_policy(ContainerName=name)
|
||||||
ContainerName=container["Name"], Policy="container-policy"
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
)
|
assert response["Policy"] == "container-policy"
|
||||||
response = client.get_container_policy(ContainerName=container["Name"])
|
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
|
||||||
response["Policy"].should.equal("container-policy")
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_put_container_policy_raises_error_if_container_does_not_exist():
|
def test_put_container_policy_raises_error_if_container_does_not_exist():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.put_container_policy(
|
client.put_container_policy(ContainerName="name", Policy="policy")
|
||||||
ContainerName="container-name", Policy="container-policy"
|
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
|
||||||
)
|
|
||||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -133,7 +119,7 @@ def test_get_container_policy_raises_error_if_container_does_not_exist():
|
|||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.get_container_policy(ContainerName="container-name")
|
client.get_container_policy(ContainerName="container-name")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -142,23 +128,21 @@ def test_get_container_policy_raises_error_if_container_does_not_have_container_
|
|||||||
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
|
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.get_container_policy(ContainerName="container-name")
|
client.get_container_policy(ContainerName="container-name")
|
||||||
ex.value.response["Error"]["Code"].should.equal("PolicyNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "PolicyNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_put_metric_policy_succeeds():
|
def test_put_metric_policy_succeeds():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
container_response = client.create_container(
|
name = "container-name"
|
||||||
ContainerName="container-name", Tags=[{"Key": "customer"}]
|
client.create_container(ContainerName=name)
|
||||||
)
|
client.put_metric_policy(
|
||||||
container = container_response["Container"]
|
ContainerName=name,
|
||||||
response = client.put_metric_policy(
|
|
||||||
ContainerName=container["Name"],
|
|
||||||
MetricPolicy={"ContainerLevelMetrics": "ENABLED"},
|
MetricPolicy={"ContainerLevelMetrics": "ENABLED"},
|
||||||
)
|
)
|
||||||
response = client.get_metric_policy(ContainerName=container["Name"])
|
response = client.get_metric_policy(ContainerName=name)
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
response["MetricPolicy"].should.equal({"ContainerLevelMetrics": "ENABLED"})
|
assert response["MetricPolicy"] == {"ContainerLevelMetrics": "ENABLED"}
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -169,7 +153,7 @@ def test_put_metric_policy_raises_error_if_container_does_not_exist():
|
|||||||
ContainerName="container-name",
|
ContainerName="container-name",
|
||||||
MetricPolicy={"ContainerLevelMetrics": "ENABLED"},
|
MetricPolicy={"ContainerLevelMetrics": "ENABLED"},
|
||||||
)
|
)
|
||||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -177,7 +161,7 @@ def test_get_metric_policy_raises_error_if_container_does_not_exist():
|
|||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.get_metric_policy(ContainerName="container-name")
|
client.get_metric_policy(ContainerName="container-name")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -186,7 +170,7 @@ def test_get_metric_policy_raises_error_if_container_does_not_have_metric_policy
|
|||||||
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
|
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.get_metric_policy(ContainerName="container-name")
|
client.get_metric_policy(ContainerName="container-name")
|
||||||
ex.value.response["Error"]["Code"].should.equal("PolicyNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "PolicyNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -194,24 +178,24 @@ def test_list_tags_for_resource():
|
|||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
tags = [{"Key": "customer"}]
|
tags = [{"Key": "customer"}]
|
||||||
|
|
||||||
create_response = client.create_container(
|
name = "Awesome container!"
|
||||||
ContainerName="Awesome container!", Tags=tags
|
client.create_container(ContainerName=name, Tags=tags)
|
||||||
)
|
|
||||||
container = create_response["Container"]
|
response = client.list_tags_for_resource(Resource=name)
|
||||||
response = client.list_tags_for_resource(Resource=container["Name"])
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
assert response["Tags"] == tags
|
||||||
response["Tags"].should.equal(tags)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_list_tags_for_resource_return_none_if_no_tags():
|
def test_list_tags_for_resource_return_none_if_no_tags():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
|
|
||||||
create_response = client.create_container(ContainerName="Awesome container!")
|
name = "Awesome container!"
|
||||||
container = create_response["Container"]
|
client.create_container(ContainerName=name)
|
||||||
response = client.list_tags_for_resource(Resource=container["Name"])
|
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
response = client.list_tags_for_resource(Resource=name)
|
||||||
response.get("Tags").should.equal(None)
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
|
assert response.get("Tags") is None
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -219,20 +203,20 @@ def test_list_tags_for_resource_return_error_for_unknown_resource():
|
|||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.list_tags_for_resource(Resource="not_existing")
|
client.list_tags_for_resource(Resource="not_existing")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ContainerNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ContainerNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
def test_delete_container():
|
def test_delete_container():
|
||||||
client = boto3.client("mediastore", region_name=region)
|
client = boto3.client("mediastore", region_name=region)
|
||||||
container_name = "Awesome container!"
|
container_name = "Awesome container!"
|
||||||
create_response = client.create_container(ContainerName=container_name)
|
client.create_container(ContainerName=container_name)
|
||||||
container = create_response["Container"]
|
|
||||||
response = client.delete_container(ContainerName=container["Name"])
|
response = client.delete_container(ContainerName=container_name)
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
containers = client.list_containers(NextToken="next-token")["Containers"]
|
|
||||||
container_exists = any(d["Name"] == container_name for d in containers)
|
containers = client.list_containers()["Containers"]
|
||||||
container_exists.should.equal(False)
|
assert not any(d["Name"] == container_name for d in containers)
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastore
|
@mock_mediastore
|
||||||
@ -242,4 +226,4 @@ def test_delete_container_raise_error_if_container_not_found():
|
|||||||
|
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.delete_container(ContainerName="notAvailable")
|
client.delete_container(ContainerName="notAvailable")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ContainerNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ContainerNotFoundException"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import sure # noqa # pylint: disable=unused-import
|
import json
|
||||||
|
|
||||||
import moto.server as server
|
import moto.server as server
|
||||||
from moto import mock_mediastore
|
from moto import mock_mediastore
|
||||||
@ -18,4 +18,4 @@ def test_mediastore_lists_containers():
|
|||||||
)
|
)
|
||||||
|
|
||||||
result = res.data.decode("utf-8")
|
result = res.data.decode("utf-8")
|
||||||
result.should.contain('"Containers": []')
|
assert json.loads(result) == {"Containers": [], "NextToken": None}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import boto3
|
import boto3
|
||||||
import pytest
|
import pytest
|
||||||
import sure # noqa # pylint: disable=unused-import
|
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
|
|
||||||
from moto import mock_mediastoredata
|
from moto import mock_mediastoredata
|
||||||
@ -12,11 +11,11 @@ region = "eu-west-1"
|
|||||||
def test_put_object():
|
def test_put_object():
|
||||||
client = boto3.client("mediastore-data", region_name=region)
|
client = boto3.client("mediastore-data", region_name=region)
|
||||||
response = client.put_object(Body="011001", Path="foo")
|
response = client.put_object(Body="011001", Path="foo")
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
response["StorageClass"].should.equal("TEMPORAL")
|
assert response["StorageClass"] == "TEMPORAL"
|
||||||
|
|
||||||
items = client.list_items()["Items"]
|
items = client.list_items()["Items"]
|
||||||
object_exists = any(d["Name"] == "foo" for d in items)
|
assert any(d["Name"] == "foo" for d in items)
|
||||||
object_exists.should.equal(True)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastoredata
|
@mock_mediastoredata
|
||||||
@ -24,7 +23,7 @@ def test_get_object_throws_not_found_error():
|
|||||||
client = boto3.client("mediastore-data", region_name=region)
|
client = boto3.client("mediastore-data", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.get_object(Path="foo")
|
client.get_object(Path="foo")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ObjectNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ObjectNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastoredata
|
@mock_mediastoredata
|
||||||
@ -32,10 +31,9 @@ def test_get_object():
|
|||||||
client = boto3.client("mediastore-data", region_name=region)
|
client = boto3.client("mediastore-data", region_name=region)
|
||||||
client.put_object(Body="011001", Path="foo")
|
client.put_object(Body="011001", Path="foo")
|
||||||
response = client.get_object(Path="foo")
|
response = client.get_object(Path="foo")
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
response["ResponseMetadata"]["HTTPHeaders"]["path"].should.equal("foo")
|
assert response["ResponseMetadata"]["HTTPHeaders"]["path"] == "foo"
|
||||||
data = response["Body"].read()
|
assert response["Body"].read() == b"011001"
|
||||||
data.should.equal(b"011001")
|
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastoredata
|
@mock_mediastoredata
|
||||||
@ -43,7 +41,7 @@ def test_delete_object_error():
|
|||||||
client = boto3.client("mediastore-data", region_name=region)
|
client = boto3.client("mediastore-data", region_name=region)
|
||||||
with pytest.raises(ClientError) as ex:
|
with pytest.raises(ClientError) as ex:
|
||||||
client.delete_object(Path="foo")
|
client.delete_object(Path="foo")
|
||||||
ex.value.response["Error"]["Code"].should.equal("ObjectNotFoundException")
|
assert ex.value.response["Error"]["Code"] == "ObjectNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastoredata
|
@mock_mediastoredata
|
||||||
@ -52,19 +50,19 @@ def test_delete_object_succeeds():
|
|||||||
object_path = "foo"
|
object_path = "foo"
|
||||||
client.put_object(Body="011001", Path=object_path)
|
client.put_object(Body="011001", Path=object_path)
|
||||||
response = client.delete_object(Path=object_path)
|
response = client.delete_object(Path=object_path)
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
|
||||||
items = client.list_items()["Items"]
|
|
||||||
len(items).should.equal(0)
|
assert len(client.list_items()["Items"]) == 0
|
||||||
|
|
||||||
|
|
||||||
@mock_mediastoredata
|
@mock_mediastoredata
|
||||||
def test_list_items():
|
def test_list_items():
|
||||||
client = boto3.client("mediastore-data", region_name=region)
|
client = boto3.client("mediastore-data", region_name=region)
|
||||||
items = client.list_items()["Items"]
|
assert len(client.list_items()["Items"]) == 0
|
||||||
len(items).should.equal(0)
|
|
||||||
object_path = "foo"
|
object_path = "foo"
|
||||||
client.put_object(Body="011001", Path=object_path)
|
client.put_object(Body="011001", Path=object_path)
|
||||||
|
|
||||||
items = client.list_items()["Items"]
|
items = client.list_items()["Items"]
|
||||||
len(items).should.equal(1)
|
assert len(items) == 1
|
||||||
object_exists = any(d["Name"] == object_path for d in items)
|
assert any(d["Name"] == object_path for d in items)
|
||||||
object_exists.should.equal(True)
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import sure # noqa # pylint: disable=unused-import
|
import json
|
||||||
|
|
||||||
import moto.server as server
|
import moto.server as server
|
||||||
from moto import mock_mediastoredata
|
from moto import mock_mediastoredata
|
||||||
@ -12,5 +12,5 @@ Test the different server responses
|
|||||||
def test_mediastore_lists_containers():
|
def test_mediastore_lists_containers():
|
||||||
backend = server.create_backend_app("mediastore-data")
|
backend = server.create_backend_app("mediastore-data")
|
||||||
test_client = backend.test_client()
|
test_client = backend.test_client()
|
||||||
response = test_client.get("/").data
|
body = test_client.get("/").data.decode("utf-8")
|
||||||
response.should.contain(b'"Items": []')
|
assert json.loads(body) == {"Items": []}
|
||||||
|
Loading…
Reference in New Issue
Block a user