Media package client error additional handling (#4011)

* Add delete container and list tags endpoints to MediaStore

* Black reformat

* Fixed Lint problems

* Check if dictionary was deleted effectively

* lint fix

* MediaPackageClientError

* Lint Fix

* Test unknown channel describe

* Concatenation Fix

* MediaPackage - fix error message

* MediaPackage Test Fix and TryError

* Lint

Co-authored-by: av <arcovoltaico@gmail.com>
Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
Jordi Alhambra 2021-06-16 21:07:46 +01:00 committed by GitHub
commit 407d5c853d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 94 additions and 21 deletions

View file

@ -5,6 +5,7 @@ from collections import OrderedDict
from boto3 import Session
from moto.core import BaseBackend, BaseModel
from .exceptions import ClientError
@ -109,9 +110,14 @@ class MediaPackageBackend(BaseBackend):
raise ClientError(error, "channel with id={} not found".format(id))
def delete_channel(self, id):
channel = self._channels[id]
del self._channels[id]
return channel.to_dict()
try:
channel = self._channels[id]
del self._channels[id]
return channel.to_dict()
except KeyError:
error = "NotFoundException"
raise ClientError(error, "channel with id={} not found".format(id))
def create_origin_endpoint(
self,
@ -156,8 +162,12 @@ class MediaPackageBackend(BaseBackend):
return origin_endpoint
def describe_origin_endpoint(self, id):
origin_endpoint = self._origin_endpoints[id]
return origin_endpoint.to_dict()
try:
origin_endpoint = self._origin_endpoints[id]
return origin_endpoint.to_dict()
except KeyError:
error = "NotFoundException"
raise ClientError(error, "origin endpoint with id={} not found".format(id))
def list_origin_endpoints(self):
origin_endpoints = list(self._origin_endpoints.values())
@ -165,9 +175,13 @@ class MediaPackageBackend(BaseBackend):
return response_origin_endpoints
def delete_origin_endpoint(self, id):
origin_endpoint = self._origin_endpoints[id]
del self._origin_endpoints[id]
return origin_endpoint.to_dict()
try:
origin_endpoint = self._origin_endpoints[id]
del self._origin_endpoints[id]
return origin_endpoint.to_dict()
except KeyError:
error = "NotFoundException"
raise ClientError(error, "origin endpoint with id={} not found".format(id))
def update_origin_endpoint(
self,
@ -184,19 +198,24 @@ class MediaPackageBackend(BaseBackend):
time_delay_seconds,
whitelist,
):
origin_endpoint = self._origin_endpoints[id]
origin_endpoint.authorization = authorization
origin_endpoint.cmaf_package = cmaf_package
origin_endpoint.dash_package = dash_package
origin_endpoint.description = description
origin_endpoint.hls_package = hls_package
origin_endpoint.manifest_name = manifest_name
origin_endpoint.mss_package = mss_package
origin_endpoint.origination = origination
origin_endpoint.startover_window_seconds = startover_window_seconds
origin_endpoint.time_delay_seconds = time_delay_seconds
origin_endpoint.whitelist = whitelist
return origin_endpoint
try:
origin_endpoint = self._origin_endpoints[id]
origin_endpoint.authorization = authorization
origin_endpoint.cmaf_package = cmaf_package
origin_endpoint.dash_package = dash_package
origin_endpoint.description = description
origin_endpoint.hls_package = hls_package
origin_endpoint.manifest_name = manifest_name
origin_endpoint.mss_package = mss_package
origin_endpoint.origination = origination
origin_endpoint.startover_window_seconds = startover_window_seconds
origin_endpoint.time_delay_seconds = time_delay_seconds
origin_endpoint.whitelist = whitelist
return origin_endpoint
except KeyError:
error = "NotFoundException"
raise ClientError(error, "origin endpoint with id={} not found".format(id))
mediapackage_backends = {}