Replace sure with regular assertions (#6594)

This commit is contained in:
kbalk 2023-08-04 10:14:14 -04:00 committed by GitHub
parent b32c5e8d96
commit 6a2131358a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 330 additions and 322 deletions

View File

@ -1,21 +1,16 @@
"""Test the different server responses."""
from datetime import datetime
import re
import sure # noqa # pylint: disable=unused-import
import moto.server as server
"""
Test the different server responses
"""
def test_ses_list_identities():
backend = server.create_backend_app("ses")
test_client = backend.test_client()
res = test_client.get("/?Action=ListIdentities")
res.data.should.contain(b"ListIdentitiesResponse")
assert b"ListIdentitiesResponse" in res.data
def test_ses_get_send_statistics():
@ -23,7 +18,7 @@ def test_ses_get_send_statistics():
test_client = backend.test_client()
res = test_client.get("/?Action=GetSendStatistics")
res.data.should.contain(b"GetSendStatisticsResponse")
assert b"GetSendStatisticsResponse" in res.data
# Timestamps must be in ISO 8601 format
groups = re.search("<Timestamp>(.*)</Timestamp>", res.data.decode("utf-8"))

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
import boto3
import json
import boto3
import sure # noqa # pylint: disable=unused-import
from moto import mock_ses, mock_sns, mock_sqs
from moto.ses.models import SESFeedback
@ -57,18 +58,18 @@ def __test_sns_feedback__(addr, expected_msg, raw_email=False):
)
# Send the message
kwargs = dict(
Source="test@" + domain,
Destination={
kwargs = {
"Source": "test@" + domain,
"Destination": {
"ToAddresses": [addr + "@" + domain],
"CcAddresses": ["test_cc@" + domain],
"BccAddresses": ["test_bcc@" + domain],
},
Message={
"Message": {
"Subject": {"Data": "test subject"},
"Body": {"Text": {"Data": "test body"}},
},
)
}
if raw_email:
kwargs.pop("Message")
kwargs.pop("Destination")
@ -139,22 +140,16 @@ def test_get_identity_notification_attributes_default_values():
resp = ses.get_identity_notification_attributes(
Identities=["test@example.com", "another@example.com"]
)["NotificationAttributes"]
resp.should.have.length_of(2)
resp.should.have.key("test@example.com")
resp.should.have.key("another@example.com")
resp["test@example.com"].should.have.key("ForwardingEnabled").equal(True)
resp["test@example.com"].should.have.key(
"HeadersInBounceNotificationsEnabled"
).equal(False)
resp["test@example.com"].should.have.key(
"HeadersInComplaintNotificationsEnabled"
).equal(False)
resp["test@example.com"].should.have.key(
"HeadersInDeliveryNotificationsEnabled"
).equal(False)
resp["test@example.com"].shouldnt.have.key("BounceTopic")
resp["test@example.com"].shouldnt.have.key("ComplaintTopic")
resp["test@example.com"].shouldnt.have.key("DeliveryTopic")
assert len(resp) == 2
assert "test@example.com" in resp
assert "another@example.com" in resp
assert resp["test@example.com"]["ForwardingEnabled"] is True
assert resp["test@example.com"]["HeadersInBounceNotificationsEnabled"] is False
assert resp["test@example.com"]["HeadersInComplaintNotificationsEnabled"] is False
assert resp["test@example.com"]["HeadersInDeliveryNotificationsEnabled"] is False
assert "BounceTopic" not in resp["test@example.com"]
assert "ComplaintTopic" not in resp["test@example.com"]
assert "DeliveryTopic" not in resp["test@example.com"]
@mock_ses
@ -166,7 +161,7 @@ def test_set_identity_feedback_forwarding_enabled():
resp = ses.get_identity_notification_attributes(Identities=["test@example.com"])[
"NotificationAttributes"
]
resp["test@example.com"].should.have.key("ForwardingEnabled").equal(True)
assert resp["test@example.com"]["ForwardingEnabled"] is True
ses.set_identity_feedback_forwarding_enabled(
Identity="test@example.com", ForwardingEnabled=False
@ -175,7 +170,7 @@ def test_set_identity_feedback_forwarding_enabled():
resp = ses.get_identity_notification_attributes(Identities=["test@example.com"])[
"NotificationAttributes"
]
resp["test@example.com"].should.have.key("ForwardingEnabled").equal(False)
assert resp["test@example.com"]["ForwardingEnabled"] is False
ses.set_identity_feedback_forwarding_enabled(
Identity="test@example.com", ForwardingEnabled=True
@ -184,4 +179,4 @@ def test_set_identity_feedback_forwarding_enabled():
resp = ses.get_identity_notification_attributes(Identities=["test@example.com"])[
"NotificationAttributes"
]
resp["test@example.com"].should.have.key("ForwardingEnabled").equal(True)
assert resp["test@example.com"]["ForwardingEnabled"] is True

View File

@ -1,14 +1,12 @@
import sure # noqa # pylint: disable=unused-import
from moto.ses.utils import is_valid_address
def test_is_valid_address():
msg = is_valid_address("test@example.com")
msg.should.equal(None)
assert msg is None
msg = is_valid_address("test@")
msg.should.be.a(str)
assert isinstance(msg, str)
msg = is_valid_address("test")
msg.should.be.a(str)
assert isinstance(msg, str)

View File

@ -1,33 +1,36 @@
from moto.ses.template import parse_template
import sure # noqa # pylint: disable=unused-import
def test_template_without_args():
parse_template("some template", template_data={}).should.equal("some template")
assert parse_template("some template", template_data={}) == "some template"
def test_template_with_simple_arg():
t = "Dear {{name}},"
parse_template(t, template_data={"name": "John"}).should.equal("Dear John,")
template = "Dear {{name}},"
assert parse_template(template, template_data={"name": "John"}) == "Dear John,"
def test_template_with_foreach():
t = "List:{{#each l}} - {{obj}}{{/each}} and other things"
template = "List:{{#each l}} - {{obj}}{{/each}} and other things"
kwargs = {"l": [{"obj": "it1"}, {"obj": "it2"}]}
parse_template(t, kwargs).should.equal("List: - it1 - it2 and other things")
assert parse_template(template, kwargs) == "List: - it1 - it2 and other things"
def test_template_with_multiple_foreach():
t = "{{#each l}} - {{obj}}{{/each}} and list 2 {{#each l2}} {{o1}} {{o2}} {{/each}}"
template = (
"{{#each l}} - {{obj}}{{/each}} and list 2 {{#each l2}} {{o1}} {{o2}} {{/each}}"
)
kwargs = {
"l": [{"obj": "it1"}, {"obj": "it2"}],
"l2": [{"o1": "ob1", "o2": "ob2"}, {"o1": "oc1", "o2": "oc2"}],
}
parse_template(t, kwargs).should.equal(" - it1 - it2 and list 2 ob1 ob2 oc1 oc2 ")
assert (
parse_template(template, kwargs) == " - it1 - it2 and list 2 ob1 ob2 oc1 oc2 "
)
def test_template_with_single_curly_brace():
t = "Dear {{name}} my {brace} is fine."
parse_template(t, template_data={"name": "John"}).should.equal(
template = "Dear {{name}} my {brace} is fine."
assert parse_template(template, template_data={"name": "John"}) == (
"Dear John my {brace} is fine."
)