Techdebt: Replace sure with regular assertions in MQ (#6662)

This commit is contained in:
Bert Blommers 2023-08-15 07:59:14 +00:00 committed by GitHub
parent 254ecc5e4f
commit dc32eb86a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 170 additions and 174 deletions

View File

@ -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_mq from moto import mock_mq
@ -23,8 +22,8 @@ def test_create_broker_minimal():
Users=[{"Username": "admin", "Password": "adm1n"}], Users=[{"Username": "admin", "Password": "adm1n"}],
) )
resp.should.have.key("BrokerId") assert "BrokerId" in resp
resp.should.have.key("BrokerArn").match("arn:aws") assert resp["BrokerArn"].startswith("arn:aws")
@mock_mq @mock_mq
@ -44,7 +43,7 @@ def test_create_with_tags():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("Tags").equals({"key1": "val2", "key2": "val2"}) assert resp["Tags"] == {"key1": "val2", "key2": "val2"}
@mock_mq @mock_mq
@ -75,14 +74,14 @@ def test_create_with_multiple_users():
)["BrokerId"] )["BrokerId"]
user1 = client.describe_user(BrokerId=broker_id, Username="SecondTest") user1 = client.describe_user(BrokerId=broker_id, Username="SecondTest")
user1.should.have.key("Username").equals("SecondTest") assert user1["Username"] == "SecondTest"
user1.should.have.key("Groups").equals(["second", "first", "third"]) assert user1["Groups"] == ["second", "first", "third"]
user1.should.have.key("ConsoleAccess").equals(True) assert user1["ConsoleAccess"] is True
user2 = client.describe_user(BrokerId=broker_id, Username="Test") user2 = client.describe_user(BrokerId=broker_id, Username="Test")
user2.should.have.key("Username").equals("Test") assert user2["Username"] == "Test"
user2.should.have.key("Groups").equals([]) assert user2["Groups"] == []
user2.should.have.key("ConsoleAccess").equals(False) assert user2["ConsoleAccess"] is False
@mock_mq @mock_mq
@ -103,10 +102,8 @@ def test_create_with_configuration():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("Configurations") assert "Configurations" in resp
resp["Configurations"].should.have.key("Current").equals( assert resp["Configurations"]["Current"] == {"Id": "config_id_x", "Revision": 3}
{"Id": "config_id_x", "Revision": 3}
)
@mock_mq @mock_mq
@ -131,10 +128,8 @@ def test_update_with_configuration():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("Configurations") assert "Configurations" in resp
resp["Configurations"].should.have.key("Current").equals( assert resp["Configurations"]["Current"] == {"Id": "config_id_x", "Revision": 2}
{"Id": "config_id_x", "Revision": 2}
)
@mock_mq @mock_mq
@ -152,9 +147,9 @@ def test_delete_broker():
)["BrokerId"] )["BrokerId"]
resp = client.delete_broker(BrokerId=broker_id) resp = client.delete_broker(BrokerId=broker_id)
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
client.list_brokers().should.have.key("BrokerSummaries").length_of(0) assert len(client.list_brokers()["BrokerSummaries"]) == 0
@mock_mq @mock_mq
@ -187,37 +182,33 @@ def test_describe_broker():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
resp.should.have.key("BrokerArn").match("arn:aws") assert resp["BrokerArn"].startswith("arn:aws")
resp.should.have.key("BrokerState").equals("RUNNING") assert resp["BrokerState"] == "RUNNING"
resp.should.have.key("Created") assert "Created" in resp
resp.should.have.key("AuthenticationStrategy").equals("SIMPLE") assert resp["AuthenticationStrategy"] == "SIMPLE"
resp.should.have.key("AutoMinorVersionUpgrade").equals(False) assert resp["AutoMinorVersionUpgrade"] is False
resp.should.have.key("BrokerName").equals("testbroker") assert resp["BrokerName"] == "testbroker"
resp.should.have.key("DeploymentMode").equals("dm") assert resp["DeploymentMode"] == "dm"
resp.should.have.key("EncryptionOptions").equals( assert resp["EncryptionOptions"] == {"KmsKeyId": "kms-key", "UseAwsOwnedKey": False}
{"KmsKeyId": "kms-key", "UseAwsOwnedKey": False} assert resp["EngineType"] == "ACTIVEMQ"
) assert resp["EngineVersion"] == "version"
resp.should.have.key("EngineType").equals("ACTIVEMQ") assert resp["HostInstanceType"] == "hit"
resp.should.have.key("EngineVersion").equals("version") assert resp["LdapServerMetadata"] == {
resp.should.have.key("HostInstanceType").equals("hit") "Hosts": ["host1"],
resp.should.have.key("LdapServerMetadata").equals( "RoleBase": "role_base_thingy",
{ "RoleSearchMatching": "rsm",
"Hosts": ["host1"], "ServiceAccountUsername": "sau",
"RoleBase": "role_base_thingy", "UserBase": "ub",
"RoleSearchMatching": "rsm", "UserSearchMatching": "usm",
"ServiceAccountUsername": "sau", }
"UserBase": "ub", assert resp["PubliclyAccessible"] is True
"UserSearchMatching": "usm", assert resp["SecurityGroups"] == ["secgroup1"]
} assert resp["StorageType"] == "efs"
) assert resp["SubnetIds"] == ["s-id"]
resp.should.have.key("PubliclyAccessible").equals(True) assert resp["Users"] == [{"Username": "admin"}]
resp.should.have.key("SecurityGroups").equals(["secgroup1"])
resp.should.have.key("StorageType").equals("efs")
resp.should.have.key("SubnetIds").equals(["s-id"])
resp.should.have.key("Users").equals([{"Username": "admin"}])
@mock_mq @mock_mq
@ -236,22 +227,24 @@ def test_describe_broker_with_defaults():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("BrokerInstances").length_of(1) assert len(resp["BrokerInstances"]) == 1
resp.should.have.key("Configurations") assert "Configurations" in resp
resp["Configurations"].should.have.key("Current") assert "Current" in resp["Configurations"]
resp["Configurations"].should.have.key("History").length_of(0) assert len(resp["Configurations"]["History"]) == 0
resp["Configurations"].shouldnt.have.key("Pending") assert "Pending" not in resp["Configurations"]
resp.should.have.key("EncryptionOptions").equals({"UseAwsOwnedKey": True}) assert resp["EncryptionOptions"] == {"UseAwsOwnedKey": True}
resp.should.have.key("MaintenanceWindowStartTime").equals( assert resp["MaintenanceWindowStartTime"] == {
{"DayOfWeek": "Sunday", "TimeOfDay": "00:00", "TimeZone": "UTC"} "DayOfWeek": "Sunday",
) "TimeOfDay": "00:00",
"TimeZone": "UTC",
}
resp.should.have.key("Logs").equals({"Audit": False, "General": False}) assert resp["Logs"] == {"Audit": False, "General": False}
resp.should.have.key("SubnetIds").length_of(1) assert len(resp["SubnetIds"]) == 1
@mock_mq @mock_mq
@ -270,14 +263,15 @@ def test_describe_multiple_rabbits():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("BrokerInstances") assert "BrokerInstances" in resp
resp["BrokerInstances"][0]["ConsoleURL"].should.equal( assert (
"https://0000.mq.us-east-2.amazonaws.com" resp["BrokerInstances"][0]["ConsoleURL"]
== "https://0000.mq.us-east-2.amazonaws.com"
) )
resp["BrokerInstances"][0]["Endpoints"].should.have.length_of(1) assert len(resp["BrokerInstances"][0]["Endpoints"]) == 1
resp.shouldnt.have.key("Configurations") assert "Configurations" not in resp
resp.should.have.key("Logs").equals({"General": False}) assert resp["Logs"] == {"General": False}
resp.should.have.key("SubnetIds").length_of(4) assert len(resp["SubnetIds"]) == 4
@mock_mq @mock_mq
@ -297,8 +291,8 @@ def test_describe_active_mq_with_standby():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
# Instances and subnets in two regions - one active, one standby # Instances and subnets in two regions - one active, one standby
resp.should.have.key("BrokerInstances").length_of(2) assert len(resp["BrokerInstances"]) == 2
resp.should.have.key("SubnetIds").length_of(2) assert len(resp["SubnetIds"]) == 2
@mock_mq @mock_mq
@ -308,9 +302,10 @@ def test_describe_broker_unknown():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.describe_broker(BrokerId="unknown") client.describe_broker(BrokerId="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert (
"Can't find requested broker [unknown]. Make sure your broker exists." err["Message"]
== "Can't find requested broker [unknown]. Make sure your broker exists."
) )
@ -319,7 +314,7 @@ def test_list_brokers_empty():
client = boto3.client("mq", region_name="eu-west-1") client = boto3.client("mq", region_name="eu-west-1")
resp = client.list_brokers() resp = client.list_brokers()
resp.should.have.key("BrokerSummaries").equals([]) assert resp["BrokerSummaries"] == []
@mock_mq @mock_mq
@ -338,19 +333,19 @@ def test_list_brokers():
resp = client.list_brokers() resp = client.list_brokers()
resp.should.have.key("BrokerSummaries").length_of(1) assert len(resp["BrokerSummaries"]) == 1
summary = resp["BrokerSummaries"][0] summary = resp["BrokerSummaries"][0]
summary.should.have.key("BrokerArn") assert "BrokerArn" in summary
summary.should.have.key("BrokerId").equals(broker_id) assert summary["BrokerId"] == broker_id
summary.should.have.key("BrokerName").equals("testbroker") assert summary["BrokerName"] == "testbroker"
summary.should.have.key("BrokerState").equals("RUNNING") assert summary["BrokerState"] == "RUNNING"
summary.should.have.key("Created") assert "Created" in summary
summary.should.have.key("DeploymentMode").equals("dm") assert summary["DeploymentMode"] == "dm"
summary.should.have.key("EngineType").equals("ACTIVEMQ") assert summary["EngineType"] == "ACTIVEMQ"
summary.should.have.key("HostInstanceType").equals("hit") assert summary["HostInstanceType"] == "hit"
summary.shouldnt.have.key("Users") assert "Users" not in summary
@mock_mq @mock_mq
@ -369,11 +364,11 @@ def test_update_broker_single_attribute():
resp = client.update_broker(AutoMinorVersionUpgrade=True, BrokerId=broker_id) resp = client.update_broker(AutoMinorVersionUpgrade=True, BrokerId=broker_id)
# Changed # Changed
resp.should.have.key("AutoMinorVersionUpgrade").equals(True) assert resp["AutoMinorVersionUpgrade"] is True
# Unchanged # Unchanged
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
resp.should.have.key("EngineVersion").equals("version") assert resp["EngineVersion"] == "version"
@mock_mq @mock_mq
@ -399,13 +394,13 @@ def test_update_broker_multiple_attributes():
) )
# Changed # Changed
resp.should.have.key("AutoMinorVersionUpgrade").equals(True) assert resp["AutoMinorVersionUpgrade"] is True
resp.should.have.key("Logs").equals({"Audit": True, "General": True}) assert resp["Logs"] == {"Audit": True, "General": True}
resp.should.have.key("EngineVersion").equals("version2") assert resp["EngineVersion"] == "version2"
resp.should.have.key("SecurityGroups").equals(["sg-1", "sg-2"]) assert resp["SecurityGroups"] == ["sg-1", "sg-2"]
# Unchanged # Unchanged
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
@mock_mq @mock_mq

View File

@ -3,7 +3,6 @@ import base64
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_mq from moto import mock_mq
@ -20,19 +19,20 @@ def test_create_configuration_minimal():
EngineType="ACTIVEMQ", EngineVersion="rabbit1", Name="myconfig" EngineType="ACTIVEMQ", EngineVersion="rabbit1", Name="myconfig"
) )
resp.should.have.key("Id").match("^c-") assert resp["Id"].startswith("c-")
resp.should.have.key("Arn").equals( assert (
f"arn:aws:mq:ap-southeast-1:{ACCOUNT_ID}:configuration:{resp['Id']}" resp["Arn"]
== f"arn:aws:mq:ap-southeast-1:{ACCOUNT_ID}:configuration:{resp['Id']}"
) )
resp.should.have.key("AuthenticationStrategy").equals("simple") assert resp["AuthenticationStrategy"] == "simple"
resp.should.have.key("Created") assert "Created" in resp
resp.should.have.key("Name").equals("myconfig") assert resp["Name"] == "myconfig"
resp.should.have.key("LatestRevision") assert "LatestRevision" in resp
revision = resp["LatestRevision"] revision = resp["LatestRevision"]
revision.should.have.key("Created") assert "Created" in revision
revision.should.have.key("Description") assert "Description" in revision
revision.should.have.key("Revision").equals(1) assert revision["Revision"] == 1
@mock_mq @mock_mq
@ -44,9 +44,10 @@ def test_create_configuration_for_rabbitmq():
EngineType="RABBITMQ", EngineVersion="rabbit1", Name="myconfig" EngineType="RABBITMQ", EngineVersion="rabbit1", Name="myconfig"
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("BadRequestException") assert err["Code"] == "BadRequestException"
err["Message"].should.equal( assert (
"Broker engine type [RABBITMQ] does not support configuration." err["Message"]
== "Broker engine type [RABBITMQ] does not support configuration."
) )
@ -59,9 +60,10 @@ def test_create_configuration_for_unknown_engine():
EngineType="unknown", EngineVersion="rabbit1", Name="myconfig" EngineType="unknown", EngineVersion="rabbit1", Name="myconfig"
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("BadRequestException") assert err["Code"] == "BadRequestException"
err["Message"].should.equal( assert (
"Broker engine type [unknown] is invalid. Valid values are: [ACTIVEMQ]" err["Message"]
== "Broker engine type [unknown] is invalid. Valid values are: [ACTIVEMQ]"
) )
@ -74,19 +76,19 @@ def test_describe_configuration():
resp = client.describe_configuration(ConfigurationId=config_id) resp = client.describe_configuration(ConfigurationId=config_id)
resp.should.have.key("Id").match("^c-") assert resp["Id"].startswith("c-")
resp.should.have.key("Arn").equals( assert (
f"arn:aws:mq:eu-north-1:{ACCOUNT_ID}:configuration:{resp['Id']}" resp["Arn"] == f"arn:aws:mq:eu-north-1:{ACCOUNT_ID}:configuration:{resp['Id']}"
) )
resp.should.have.key("AuthenticationStrategy").equals("simple") assert resp["AuthenticationStrategy"] == "simple"
resp.should.have.key("Created") assert "Created" in resp
resp.should.have.key("Name").equals("myconfig") assert resp["Name"] == "myconfig"
resp.should.have.key("LatestRevision") assert "LatestRevision" in resp
revision = resp["LatestRevision"] revision = resp["LatestRevision"]
revision.should.have.key("Created") assert "Created" in revision
revision.should.have.key("Description") assert "Description" in revision
revision.should.have.key("Revision").equals(1) assert revision["Revision"] == 1
@mock_mq @mock_mq
@ -100,13 +102,13 @@ def test_describe_configuration_revision():
ConfigurationId=config_id, ConfigurationRevision="1" ConfigurationId=config_id, ConfigurationRevision="1"
) )
resp.should.have.key("ConfigurationId").equals(config_id) assert resp["ConfigurationId"] == config_id
resp.should.have.key("Created") assert "Created" in resp
resp.should.have.key("Description").equals( assert (
"Auto-generated default for myconfig on ActiveMQ 5.16.3" resp["Description"] == "Auto-generated default for myconfig on ActiveMQ 5.16.3"
) )
resp.should.have.key("Data") assert "Data" in resp
@mock_mq @mock_mq
@ -117,9 +119,10 @@ def test_describe_configuration_unknown():
client.describe_configuration(ConfigurationId="c-unknown") client.describe_configuration(ConfigurationId="c-unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert (
"Can't find requested configuration [c-unknown]. Make sure your configuration exists." err["Message"]
== "Can't find requested configuration [c-unknown]. Make sure your configuration exists."
) )
@ -129,7 +132,7 @@ def test_list_configurations_empty():
resp = client.list_configurations() resp = client.list_configurations()
resp.should.have.key("Configurations").equals([]) assert resp["Configurations"] == []
@mock_mq @mock_mq
@ -141,15 +144,15 @@ def test_list_configurations():
resp = client.list_configurations() resp = client.list_configurations()
resp.should.have.key("Configurations").length_of(1) assert len(resp["Configurations"]) == 1
config = resp["Configurations"][0] config = resp["Configurations"][0]
config.should.have.key("Arn").match("arn:aws") assert config["Arn"].startswith("arn:aws")
config.should.have.key("Created") assert "Created" in config
config.should.have.key("Id").equals(config_id) assert config["Id"] == config_id
config.should.have.key("Name").equals("myconfig") assert config["Name"] == "myconfig"
config.should.have.key("EngineType").equals("ACTIVEMQ") assert config["EngineType"] == "ACTIVEMQ"
config.should.have.key("EngineVersion").equals("active1") assert config["EngineVersion"] == "active1"
@mock_mq @mock_mq
@ -165,16 +168,16 @@ def test_update_configuration():
Description="updated config", Description="updated config",
) )
resp.should.have.key("Arn").match("arn:aws:mq") assert resp["Arn"].startswith("arn:aws:mq")
resp.should.have.key("Created") assert "Created" in resp
resp.should.have.key("Id") assert "Id" in resp
resp.should.have.key("Name").equals("myconfig") assert resp["Name"] == "myconfig"
resp.should.have.key("LatestRevision") assert "LatestRevision" in resp
revision = resp["LatestRevision"] revision = resp["LatestRevision"]
revision.should.have.key("Created") assert "Created" in revision
revision.should.have.key("Description").equals("updated config") assert revision["Description"] == "updated config"
revision.should.have.key("Revision").equals(2) assert revision["Revision"] == 2
@mock_mq @mock_mq
@ -207,4 +210,4 @@ def test_update_configuration_to_ldap():
resp = client.describe_configuration(ConfigurationId=config_id) resp = client.describe_configuration(ConfigurationId=config_id)
resp.should.have.key("AuthenticationStrategy").equals("ldap") assert resp["AuthenticationStrategy"] == "ldap"

View File

@ -1,5 +1,4 @@
import boto3 import boto3
import sure # noqa # pylint: disable=unused-import
from moto import mock_mq from moto import mock_mq
@ -21,7 +20,7 @@ def test_create_broker_with_tags():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("Tags").equals({"key1": "val2", "key2": "val2"}) assert resp["Tags"] == {"key1": "val2", "key2": "val2"}
@mock_mq @mock_mq
@ -45,7 +44,7 @@ def test_create_tags():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("Tags").equals({"key1": "val2", "key2": "val2"}) assert resp["Tags"] == {"key1": "val2", "key2": "val2"}
@mock_mq @mock_mq
@ -71,7 +70,7 @@ def test_delete_tags():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("Tags").equals({"key2": "val2"}) assert resp["Tags"] == {"key2": "val2"}
@mock_mq @mock_mq
@ -85,11 +84,11 @@ def test_create_configuration_with_tags():
) )
# The CreateConfiguration call does not return tags # The CreateConfiguration call does not return tags
resp.shouldnt.have.key("Tags") assert "Tags" not in resp
# Only when describing will they be returned # Only when describing will they be returned
resp = client.describe_configuration(ConfigurationId=resp["Id"]) resp = client.describe_configuration(ConfigurationId=resp["Id"])
resp.should.have.key("Tags").equals({"key1": "val1", "key2": "val2"}) assert resp["Tags"] == {"key1": "val1", "key2": "val2"}
@mock_mq @mock_mq
@ -106,4 +105,4 @@ def test_add_tags_to_configuration():
# Only when describing will they be returned # Only when describing will they be returned
resp = client.describe_configuration(ConfigurationId=resp["Id"]) resp = client.describe_configuration(ConfigurationId=resp["Id"])
resp.should.have.key("Tags").equals({"key1": "val1", "key2": "val2"}) assert resp["Tags"] == {"key1": "val1", "key2": "val2"}

View File

@ -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_mq from moto import mock_mq
@ -24,7 +23,7 @@ def test_create_user():
resp = client.describe_broker(BrokerId=broker_id) resp = client.describe_broker(BrokerId=broker_id)
resp.should.have.key("Users").equals([{"Username": "admin"}]) assert resp["Users"] == [{"Username": "admin"}]
@mock_mq @mock_mq
@ -51,10 +50,10 @@ def test_describe_user():
resp = client.describe_user(BrokerId=broker_id, Username="admin") resp = client.describe_user(BrokerId=broker_id, Username="admin")
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
resp.should.have.key("ConsoleAccess").equals(True) assert resp["ConsoleAccess"] is True
resp.should.have.key("Groups").equals(["group1", "group2"]) assert resp["Groups"] == ["group1", "group2"]
resp.should.have.key("Username").equals("admin") assert resp["Username"] == "admin"
@mock_mq @mock_mq
@ -74,9 +73,10 @@ def test_describe_user_unknown():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.describe_user(BrokerId=broker_id, Username="unknown") client.describe_user(BrokerId=broker_id, Username="unknown")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("NotFoundException") assert err["Code"] == "NotFoundException"
err["Message"].should.equal( assert (
"Can't find requested user [unknown]. Make sure your user exists." err["Message"]
== "Can't find requested user [unknown]. Make sure your user exists."
) )
@ -96,8 +96,8 @@ def test_list_users_empty():
resp = client.list_users(BrokerId=broker_id) resp = client.list_users(BrokerId=broker_id)
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
resp.should.have.key("Users").equals([]) assert resp["Users"] == []
@mock_mq @mock_mq
@ -118,10 +118,10 @@ def test_list_users():
resp = client.list_users(BrokerId=broker_id) resp = client.list_users(BrokerId=broker_id)
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
resp.should.have.key("Users").length_of(2) assert len(resp["Users"]) == 2
resp["Users"].should.contain({"Username": "admin"}) assert {"Username": "admin"} in resp["Users"]
resp["Users"].should.contain({"Username": "user1"}) assert {"Username": "user1"} in resp["Users"]
@mock_mq @mock_mq
@ -142,9 +142,9 @@ def test_update_user():
resp = client.describe_user(BrokerId=broker_id, Username="admin") resp = client.describe_user(BrokerId=broker_id, Username="admin")
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
resp.should.have.key("Groups").equals(["administrators"]) assert resp["Groups"] == ["administrators"]
resp.should.have.key("Username").equals("admin") assert resp["Username"] == "admin"
@mock_mq @mock_mq
@ -167,6 +167,6 @@ def test_delete_user():
resp = client.list_users(BrokerId=broker_id) resp = client.list_users(BrokerId=broker_id)
resp.should.have.key("BrokerId").equals(broker_id) assert resp["BrokerId"] == broker_id
resp.should.have.key("Users").length_of(1) assert len(resp["Users"]) == 1
resp["Users"].should.contain({"Username": "user1"}) assert {"Username": "user1"} in resp["Users"]

View File

@ -1,5 +1,4 @@
import json import json
import sure # noqa # pylint: disable=unused-import
from moto import mock_mq from moto import mock_mq
import moto.server as server import moto.server as server
@ -11,5 +10,5 @@ def test_mq_list():
test_client = backend.test_client() test_client = backend.test_client()
resp = test_client.get("/v1/brokers") resp = test_client.get("/v1/brokers")
resp.status_code.should.equal(200) assert resp.status_code == 200
json.loads(resp.data).should.equal({"brokerSummaries": []}) assert json.loads(resp.data) == {"brokerSummaries": []}