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