Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions moto/mediaconnect/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def __init__(self, *args, **kwargs):
self.description = None
self.flow_arn = None
self.egress_ip = None
if self.source and not self.sources:
self.sources = [
self.source,
]

def to_dict(self, include=None):
data = {
Expand Down Expand Up @@ -92,6 +96,10 @@ def create_flow(
sources,
vpc_interfaces,
):
if isinstance(source, dict) and source.get("name"):
source["sourceArn"] = "arn:aws:mediaconnect:source:{}".format(
source["name"]
)
flow = Flow(
availability_zone=availability_zone,
entitlements=entitlements,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_mediaconnect/test_mediaconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def test_create_flow_succeeds():
response["Flow"]["FlowArn"][:26].should.equal("arn:aws:mediaconnect:flow:")
response["Flow"]["Name"].should.equal("test Flow 1")
response["Flow"]["Status"].should.equal("STANDBY")
response["Flow"]["Sources"][0][
"SourceArn"
] == "arn:aws:mediaconnect:source:Source A"


@mock_mediaconnect
Expand Down
40 changes: 33 additions & 7 deletions tests/test_mediastore/test_mediastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ def test_describe_container_raises_error_if_container_does_not_exist():
)


@mock_mediastore
def test_put_lifecycle_policy_succeeds():
client = boto3.client("mediastore", region_name=region)
container_response = client.create_container(
ContainerName="container-name", Tags=[{"Key": "customer"}]
)
container = container_response["Container"]
response = client.put_lifecycle_policy(
ContainerName=container["Name"], 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
def test_put_lifecycle_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
Expand Down Expand Up @@ -97,11 +112,11 @@ def test_get_lifecycle_policy_raises_error_if_container_does_not_have_lifecycle_
ContainerName="container-name", Tags=[{"Key": "customer"}]
)
container = container_response["Container"]
client.get_container_policy.when.called_with(
client.get_lifecycle_policy.when.called_with(
ContainerName=container["Name"]
).should.throw(
ClientError,
"An error occurred (PolicyNotFoundException) when calling the GetContainerPolicy operation: The policy does not exist within the specfied container",
"An error occurred (PolicyNotFoundException) when calling the GetLifecyclePolicy operation: The policy does not exist within the specfied container",
)


Expand All @@ -112,12 +127,23 @@ def test_put_container_policy_succeeds():
ContainerName="container-name", Tags=[{"Key": "customer"}]
)
container = container_response["Container"]
response = client.put_lifecycle_policy(
ContainerName=container["Name"], LifecyclePolicy="lifecycle-policy"
response = client.put_container_policy(
ContainerName=container["Name"], Policy="container-policy"
)
response = client.get_lifecycle_policy(ContainerName=container["Name"])
response = client.get_container_policy(ContainerName=container["Name"])
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
response["LifecyclePolicy"].should.equal("lifecycle-policy")
response["Policy"].should.equal("container-policy")


@mock_mediastore
def test_put_container_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
client.put_container_policy.when.called_with(
ContainerName="container-name", Policy="container-policy",
).should.throw(
ClientError,
"An error occurred (ResourceNotFoundException) when calling the PutContainerPolicy operation: The specified container does not exist",
)


@mock_mediastore
Expand All @@ -132,7 +158,7 @@ def test_get_container_policy_raises_error_if_container_does_not_exist():


@mock_mediastore
def test_get_metric_policy_raises_error_if_container_does_not_have_container_policy():
def test_get_container_policy_raises_error_if_container_does_not_have_container_policy():
client = boto3.client("mediastore", region_name=region)
container_response = client.create_container(
ContainerName="container-name", Tags=[{"Key": "customer"}]
Expand Down
8 changes: 5 additions & 3 deletions tests/test_mediastore/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
def test_mediastore_lists_containers():
backend = server.create_backend_app("mediastore")
test_client = backend.test_client()
res = test_client.get("/")

res = test_client.get(
"/", headers={"X-Amz-Target": "MediaStore_20170901.ListContainers"},
)

result = res.data.decode("utf-8")
print(res)
print(result)
result.should.contain('"Containers": []')