Replace sure with regular assertions in sdb (#6593)
This commit is contained in:
parent
0a667f0cc3
commit
b32c5e8d96
@ -1,6 +1,5 @@
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa # pylint: disable=unused-import
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from moto import mock_sdb
|
||||
@ -14,9 +13,9 @@ def test_put_attributes_unknown_domain():
|
||||
DomainName="aaaa", ItemName="asdf", Attributes=[{"Name": "a", "Value": "b"}]
|
||||
)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("NoSuchDomain")
|
||||
err["Message"].should.equal("The specified domain does not exist.")
|
||||
err.should.have.key("BoxUsage")
|
||||
assert err["Code"] == "NoSuchDomain"
|
||||
assert err["Message"] == "The specified domain does not exist."
|
||||
assert "BoxUsage" in err
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -27,9 +26,9 @@ def test_put_attributes_invalid_domain():
|
||||
DomainName="a", ItemName="asdf", Attributes=[{"Name": "a", "Value": "b"}]
|
||||
)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidParameterValue")
|
||||
err["Message"].should.equal("Value (a) for parameter DomainName is invalid. ")
|
||||
err.should.have.key("BoxUsage")
|
||||
assert err["Code"] == "InvalidParameterValue"
|
||||
assert err["Message"] == "Value (a) for parameter DomainName is invalid. "
|
||||
assert "BoxUsage" in err
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -38,9 +37,9 @@ def test_get_attributes_unknown_domain():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
sdb.get_attributes(DomainName="aaaa", ItemName="asdf")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("NoSuchDomain")
|
||||
err["Message"].should.equal("The specified domain does not exist.")
|
||||
err.should.have.key("BoxUsage")
|
||||
assert err["Code"] == "NoSuchDomain"
|
||||
assert err["Message"] == "The specified domain does not exist."
|
||||
assert "BoxUsage" in err
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -49,9 +48,9 @@ def test_get_attributes_invalid_domain():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
sdb.get_attributes(DomainName="a", ItemName="asdf")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidParameterValue")
|
||||
err["Message"].should.equal("Value (a) for parameter DomainName is invalid. ")
|
||||
err.should.have.key("BoxUsage")
|
||||
assert err["Code"] == "InvalidParameterValue"
|
||||
assert err["Message"] == "Value (a) for parameter DomainName is invalid. "
|
||||
assert "BoxUsage" in err
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -65,7 +64,7 @@ def test_put_and_get_attributes():
|
||||
)
|
||||
|
||||
attrs = sdb.get_attributes(DomainName=name, ItemName="asdf")["Attributes"]
|
||||
attrs.should.equal([{"Name": "a", "Value": "b"}])
|
||||
assert attrs == [{"Name": "a", "Value": "b"}]
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -88,16 +87,14 @@ def test_put_multiple_and_get_attributes():
|
||||
)
|
||||
|
||||
attrs = sdb.get_attributes(DomainName=name, ItemName="asdf")["Attributes"]
|
||||
attrs.should.equal(
|
||||
[
|
||||
assert attrs == [
|
||||
{"Name": "a", "Value": "b"},
|
||||
{"Name": "a", "Value": "c"},
|
||||
{"Name": "d", "Value": "e"},
|
||||
]
|
||||
)
|
||||
|
||||
attrs = sdb.get_attributes(DomainName=name, ItemName="jklp")["Attributes"]
|
||||
attrs.should.equal([{"Name": "a", "Value": "val"}])
|
||||
assert attrs == [{"Name": "a", "Value": "val"}]
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -125,10 +122,10 @@ def test_put_replace_and_get_attributes():
|
||||
)
|
||||
|
||||
attrs = sdb.get_attributes(DomainName=name, ItemName="asdf")["Attributes"]
|
||||
attrs.should.have.length_of(3)
|
||||
attrs.should.contain({"Name": "a", "Value": "f"})
|
||||
attrs.should.contain({"Name": "d", "Value": "e"})
|
||||
attrs.should.contain({"Name": "d", "Value": "g"})
|
||||
assert len(attrs) == 3
|
||||
assert {"Name": "a", "Value": "f"} in attrs
|
||||
assert {"Name": "d", "Value": "e"} in attrs
|
||||
assert {"Name": "d", "Value": "g"} in attrs
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -144,9 +141,7 @@ def test_put_and_get_multiple_attributes():
|
||||
)
|
||||
|
||||
attrs = sdb.get_attributes(DomainName=name, ItemName="asdf")["Attributes"]
|
||||
attrs.should.equal(
|
||||
[{"Name": "a", "Value": "b"}, {"Name": "attr2", "Value": "myvalue"}]
|
||||
)
|
||||
assert attrs == [{"Name": "a", "Value": "b"}, {"Name": "attr2", "Value": "myvalue"}]
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -164,4 +159,4 @@ def test_get_attributes_by_name():
|
||||
attrs = sdb.get_attributes(
|
||||
DomainName=name, ItemName="asdf", AttributeNames=["attr2"]
|
||||
)["Attributes"]
|
||||
attrs.should.equal([{"Name": "attr2", "Value": "myvalue"}])
|
||||
assert attrs == [{"Name": "attr2", "Value": "myvalue"}]
|
||||
|
@ -1,6 +1,5 @@
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa # pylint: disable=unused-import
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from moto import mock_sdb
|
||||
@ -14,9 +13,9 @@ def test_create_domain_invalid(name):
|
||||
with pytest.raises(ClientError) as exc:
|
||||
sdb.create_domain(DomainName=name)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidParameterValue")
|
||||
err["Message"].should.equal(f"Value ({name}) for parameter DomainName is invalid. ")
|
||||
err.should.have.key("BoxUsage")
|
||||
assert err["Code"] == "InvalidParameterValue"
|
||||
assert err["Message"] == f"Value ({name}) for parameter DomainName is invalid. "
|
||||
assert "BoxUsage" in err
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -35,7 +34,7 @@ def test_create_domain_and_list():
|
||||
sdb.create_domain(DomainName="mydomain")
|
||||
|
||||
all_domains = sdb.list_domains()["DomainNames"]
|
||||
all_domains.should.equal(["mydomain"])
|
||||
assert all_domains == ["mydomain"]
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -45,7 +44,7 @@ def test_delete_domain():
|
||||
sdb.delete_domain(DomainName="mydomain")
|
||||
|
||||
all_domains = sdb.list_domains()
|
||||
all_domains.shouldnt.have.key("DomainNames")
|
||||
assert "DomainNames" not in all_domains
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -54,7 +53,7 @@ def test_delete_domain_unknown():
|
||||
sdb.delete_domain(DomainName="unknown")
|
||||
|
||||
all_domains = sdb.list_domains()
|
||||
all_domains.shouldnt.have.key("DomainNames")
|
||||
assert "DomainNames" not in all_domains
|
||||
|
||||
|
||||
@mock_sdb
|
||||
@ -63,6 +62,6 @@ def test_delete_domain_invalid():
|
||||
with pytest.raises(ClientError) as exc:
|
||||
sdb.delete_domain(DomainName="a")
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidParameterValue")
|
||||
err["Message"].should.equal("Value (a) for parameter DomainName is invalid. ")
|
||||
err.should.have.key("BoxUsage")
|
||||
assert err["Code"] == "InvalidParameterValue"
|
||||
assert err["Message"] == "Value (a) for parameter DomainName is invalid. "
|
||||
assert "BoxUsage" in err
|
||||
|
@ -1,6 +1,4 @@
|
||||
"""Test different server responses."""
|
||||
import sure # noqa # pylint: disable=unused-import
|
||||
|
||||
import moto.server as server
|
||||
from moto import mock_sdb
|
||||
|
||||
@ -11,5 +9,5 @@ def test_sdb_list():
|
||||
test_client = backend.test_client()
|
||||
|
||||
resp = test_client.post("/", data={"Action": "ListDomains"})
|
||||
resp.status_code.should.equal(200)
|
||||
str(resp.data).should.contain("ListDomainsResult")
|
||||
assert resp.status_code == 200
|
||||
assert "ListDomainsResult" in str(resp.data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user