diff --git a/tests/test_medialive/test_medialive.py b/tests/test_medialive/test_medialive.py index c1ec3503f..ce5e55df5 100644 --- a/tests/test_medialive/test_medialive.py +++ b/tests/test_medialive/test_medialive.py @@ -1,5 +1,4 @@ import boto3 -import sure # noqa # pylint: disable=unused-import from moto import mock_medialive from uuid import uuid4 @@ -111,21 +110,16 @@ def test_create_channel_succeeds(): channel_config = _create_channel_config("test channel 1") response = client.create_channel(**channel_config) + assert response["ResponseMetadata"]["HTTPStatusCode"] == 200 - response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - response["Channel"]["Arn"].should.equal( - f"arn:aws:medialive:channel:{response['Channel']['Id']}" - ) - response["Channel"]["Destinations"].should.equal(channel_config["Destinations"]) - response["Channel"]["EncoderSettings"].should.equal( - channel_config["EncoderSettings"] - ) - response["Channel"]["InputAttachments"].should.equal( - channel_config["InputAttachments"] - ) - response["Channel"]["Name"].should.equal("test channel 1") - response["Channel"]["State"].should.equal("CREATING") - response["Channel"]["Tags"]["Customer"].should.equal("moto") + channel = response["Channel"] + assert channel["Arn"] == f"arn:aws:medialive:channel:{response['Channel']['Id']}" + assert channel["Destinations"] == channel_config["Destinations"] + assert channel["EncoderSettings"] == channel_config["EncoderSettings"] + assert channel["InputAttachments"] == channel_config["InputAttachments"] + assert channel["Name"] == "test channel 1" + assert channel["State"] == "CREATING" + assert channel["Tags"]["Customer"] == "moto" @mock_medialive @@ -139,15 +133,15 @@ def test_list_channels_succeeds(): client.create_channel(**channel2_config) response = client.list_channels() - len(response["Channels"]).should.equal(2) + assert len(response["Channels"]) == 2 - response["Channels"][0]["Name"].should.equal("test channel 1") - response["Channels"][0]["ChannelClass"].should.equal("STANDARD") - response["Channels"][0]["PipelinesRunningCount"].should.equal(2) + assert response["Channels"][0]["Name"] == "test channel 1" + assert response["Channels"][0]["ChannelClass"] == "STANDARD" + assert response["Channels"][0]["PipelinesRunningCount"] == 2 - response["Channels"][1]["Name"].should.equal("test channel 2") - response["Channels"][1]["ChannelClass"].should.equal("SINGLE_PIPELINE") - response["Channels"][1]["PipelinesRunningCount"].should.equal(1) + assert response["Channels"][1]["Name"] == "test channel 2" + assert response["Channels"][1]["ChannelClass"] == "SINGLE_PIPELINE" + assert response["Channels"][1]["PipelinesRunningCount"] == 1 @mock_medialive @@ -156,11 +150,11 @@ def test_delete_channel_moves_channel_in_deleted_state(): channel_name = "test channel X" channel_config = _create_channel_config(channel_name) - create_response = client.create_channel(**channel_config) - delete_response = client.delete_channel(ChannelId=create_response["Channel"]["Id"]) + channel_id = client.create_channel(**channel_config)["Channel"]["Id"] + delete_response = client.delete_channel(ChannelId=channel_id) - delete_response["Name"].should.equal(channel_name) - delete_response["State"].should.equal("DELETING") + assert delete_response["Name"] == channel_name + assert delete_response["State"] == "DELETING" @mock_medialive @@ -169,22 +163,16 @@ def test_describe_channel_succeeds(): channel_name = "test channel X" channel_config = _create_channel_config(channel_name) - create_response = client.create_channel(**channel_config) - describe_response = client.describe_channel( - ChannelId=create_response["Channel"]["Id"] - ) + channel_id = client.create_channel(**channel_config)["Channel"]["Id"] + channel = client.describe_channel(ChannelId=channel_id) - describe_response["Arn"].should.equal( - f"arn:aws:medialive:channel:{describe_response['Id']}" - ) - describe_response["Destinations"].should.equal(channel_config["Destinations"]) - describe_response["EncoderSettings"].should.equal(channel_config["EncoderSettings"]) - describe_response["InputAttachments"].should.equal( - channel_config["InputAttachments"] - ) - describe_response["Name"].should.equal(channel_name) - describe_response["State"].should.equal("IDLE") - describe_response["Tags"]["Customer"].should.equal("moto") + assert channel["Arn"] == f"arn:aws:medialive:channel:{channel['Id']}" + assert channel["Destinations"] == channel_config["Destinations"] + assert channel["EncoderSettings"] == channel_config["EncoderSettings"] + assert channel["InputAttachments"] == channel_config["InputAttachments"] + assert channel["Name"] == channel_name + assert channel["State"] == "IDLE" + assert channel["Tags"]["Customer"] == "moto" @mock_medialive @@ -193,15 +181,12 @@ def test_start_channel_succeeds(): channel_name = "testchan1" channel_config = _create_channel_config(channel_name) - create_response = client.create_channel(**channel_config) - start_response = client.start_channel(ChannelId=create_response["Channel"]["Id"]) - start_response["Name"].should.equal(channel_name) - start_response["State"].should.equal("STARTING") + channel_id = client.create_channel(**channel_config)["Channel"]["Id"] + start_response = client.start_channel(ChannelId=channel_id) + assert start_response["Name"] == channel_name + assert start_response["State"] == "STARTING" - describe_response = client.describe_channel( - ChannelId=create_response["Channel"]["Id"] - ) - describe_response["State"].should.equal("RUNNING") + assert client.describe_channel(ChannelId=channel_id)["State"] == "RUNNING" @mock_medialive @@ -210,18 +195,14 @@ def test_stop_channel_succeeds(): channel_name = "testchan2" channel_config = _create_channel_config(channel_name) - create_response = client.create_channel(**channel_config) - channel_id = create_response["Channel"]["Id"] + channel_id = client.create_channel(**channel_config)["Channel"]["Id"] assert len(channel_id) > 1 client.start_channel(ChannelId=channel_id) stop_response = client.stop_channel(ChannelId=channel_id) - stop_response["Name"].should.equal(channel_name) - stop_response["State"].should.equal("STOPPING") + assert stop_response["Name"] == channel_name + assert stop_response["State"] == "STOPPING" - describe_response = client.describe_channel( - ChannelId=create_response["Channel"]["Id"] - ) - describe_response["State"].should.equal("IDLE") + assert client.describe_channel(ChannelId=channel_id)["State"] == "IDLE" @mock_medialive @@ -230,19 +211,17 @@ def test_update_channel_succeeds(): channel_name = "Original Channel" channel_config = _create_channel_config(channel_name) - create_response = client.create_channel(**channel_config) - channel_id = create_response["Channel"]["Id"] - assert len(channel_id) > 1 + channel_id = client.create_channel(**channel_config)["Channel"]["Id"] - update_response = client.update_channel( + updated_channel = client.update_channel( ChannelId=channel_id, Name="Updated Channel" - ) - update_response["Channel"]["State"].should.equal("UPDATING") - update_response["Channel"]["Name"].should.equal("Updated Channel") + )["Channel"] + assert updated_channel["State"] == "UPDATING" + assert updated_channel["Name"] == "Updated Channel" - describe_response = client.describe_channel(ChannelId=channel_id) - describe_response["State"].should.equal("IDLE") - describe_response["Name"].should.equal("Updated Channel") + channel = client.describe_channel(ChannelId=channel_id) + assert channel["State"] == "IDLE" + assert channel["Name"] == "Updated Channel" @mock_medialive @@ -252,24 +231,24 @@ def test_create_input_succeeds(): input_config = _create_input_config(input_name) create_response = client.create_input(**input_config) - create_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert create_response["ResponseMetadata"]["HTTPStatusCode"] == 200 r_input = create_response["Input"] input_id = r_input["Id"] assert len(input_id) > 1 - r_input["Arn"].should.equal(f"arn:aws:medialive:input:{r_input['Id']}") - r_input["Name"].should.equal(input_name) - r_input["AttachedChannels"].should.equal([]) - r_input["Destinations"].should.equal(input_config["Destinations"]) - r_input["InputClass"].should.equal("STANDARD") - r_input["InputDevices"].should.equal(input_config["InputDevices"]) - r_input["InputSourceType"].should.equal("STATIC") - r_input["MediaConnectFlows"].should.equal(input_config["MediaConnectFlows"]) - r_input["RoleArn"].should.equal(input_config["RoleArn"]) - r_input["SecurityGroups"].should.equal([]) - r_input["Sources"].should.equal(input_config["Sources"]) - r_input["State"].should.equal("CREATING") - r_input["Tags"].should.equal(input_config["Tags"]) - r_input["Type"].should.equal(input_config["Type"]) + assert r_input["Arn"] == f"arn:aws:medialive:input:{r_input['Id']}" + assert r_input["Name"] == input_name + assert r_input["AttachedChannels"] == [] + assert r_input["Destinations"] == input_config["Destinations"] + assert r_input["InputClass"] == "STANDARD" + assert r_input["InputDevices"] == input_config["InputDevices"] + assert r_input["InputSourceType"] == "STATIC" + assert r_input["MediaConnectFlows"] == input_config["MediaConnectFlows"] + assert r_input["RoleArn"] == input_config["RoleArn"] + assert r_input["SecurityGroups"] == [] + assert r_input["Sources"] == input_config["Sources"] + assert r_input["State"] == "CREATING" + assert r_input["Tags"] == input_config["Tags"] + assert r_input["Type"] == input_config["Type"] @mock_medialive @@ -279,16 +258,14 @@ def test_describe_input_succeeds(): input_config = _create_input_config(input_name) create_response = client.create_input(**input_config) - create_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - create_response["Input"]["State"].should.equal("CREATING") + assert create_response["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert create_response["Input"]["State"] == "CREATING" describe_response = client.describe_input(InputId=create_response["Input"]["Id"]) - describe_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - describe_response["Name"].should.equal(input_name) - describe_response["State"].should.equal("DETACHED") - describe_response["MediaConnectFlows"].should.equal( - input_config["MediaConnectFlows"] - ) + assert describe_response["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert describe_response["Name"] == input_name + assert describe_response["State"] == "DETACHED" + assert describe_response["MediaConnectFlows"] == input_config["MediaConnectFlows"] @mock_medialive @@ -299,11 +276,11 @@ def test_list_inputs_succeeds(): input_config2 = _create_input_config("Input Two") client.create_input(**input_config2) - response = client.list_inputs() - len(response["Inputs"]).should.equal(2) + inputs = client.list_inputs()["Inputs"] + assert len(inputs) == 2 - response["Inputs"][0]["Name"].should.equal("Input One") - response["Inputs"][1]["Name"].should.equal("Input Two") + assert inputs[0]["Name"] == "Input One" + assert inputs[1]["Name"] == "Input Two" @mock_medialive @@ -312,13 +289,13 @@ def test_delete_input_moves_input_in_deleted_state(): input_name = "test input X" input_config = _create_input_config(input_name) - create_response = client.create_input(**input_config) - delete_response = client.delete_input(InputId=create_response["Input"]["Id"]) - delete_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + input_id = client.create_input(**input_config)["Input"]["Id"] + response = client.delete_input(InputId=input_id) + assert response["ResponseMetadata"]["HTTPStatusCode"] == 200 - describe_response = client.describe_input(InputId=create_response["Input"]["Id"]) - describe_response["Name"].should.equal(input_name) - describe_response["State"].should.equal("DELETED") + input_ = client.describe_input(InputId=input_id) + assert input_["Name"] == input_name + assert input_["State"] == "DELETED" @mock_medialive @@ -327,8 +304,6 @@ def test_update_input_succeeds(): input_name = "test input X" input_config = _create_input_config(input_name) - create_response = client.create_input(**input_config) - update_response = client.update_input( - InputId=create_response["Input"]["Id"], Name="test input U" - ) - update_response["Input"]["Name"].should.equal("test input U") + input_id = client.create_input(**input_config)["Input"]["Id"] + input_ = client.update_input(InputId=input_id, Name="test input U") + assert input_["Input"]["Name"] == "test input U" diff --git a/tests/test_medialive/test_server.py b/tests/test_medialive/test_server.py index 6ebe6ebad..46e830377 100644 --- a/tests/test_medialive/test_server.py +++ b/tests/test_medialive/test_server.py @@ -1,5 +1,4 @@ -import sure # noqa # pylint: disable=unused-import - +import json import moto.server as server from moto import mock_medialive @@ -15,7 +14,7 @@ def test_medialive_list_channels(): res = test_client.get("/prod/channels") result = res.data.decode("utf-8") - result.should.contain('"channels": []') + assert json.loads(result) == {"channels": [], "nextToken": None} @mock_medialive @@ -26,4 +25,4 @@ def test_medialive_list_inputs(): res = test_client.get("/prod/inputs") result = res.data.decode("utf-8") - result.should.contain('"inputs": []') + assert json.loads(result) == {"inputs": [], "nextToken": None}