feature/support create_case, resolve_case, describe_cases and associated tests (#3776)
* feature/support create_case, resolve_case, describe_cases and associated tests * review/support - addressed PR comments - Have created a SupportCase object to persist case - Associated testing to address PR comments * Support - simplify tests * Support - Simplify tests even more Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
parent
b06e77b604
commit
74272ae51c
@ -10059,9 +10059,9 @@
|
||||
|
||||
- [ ] add_attachments_to_set
|
||||
- [ ] add_communication_to_case
|
||||
- [ ] create_case
|
||||
- [X] create_case
|
||||
- [ ] describe_attachment
|
||||
- [ ] describe_cases
|
||||
- [X] describe_cases
|
||||
- [ ] describe_communications
|
||||
- [ ] describe_services
|
||||
- [ ] describe_severity_levels
|
||||
@ -10070,7 +10070,7 @@
|
||||
- [ ] describe_trusted_advisor_check_summaries
|
||||
- [X] describe_trusted_advisor_checks
|
||||
- [X] refresh_trusted_advisor_check
|
||||
- [ ] resolve_case
|
||||
- [X] resolve_case
|
||||
</details>
|
||||
|
||||
## swf
|
||||
|
@ -3,17 +3,59 @@ from boto3 import Session
|
||||
from pkg_resources import resource_filename
|
||||
from moto.core import BaseBackend
|
||||
from moto.utilities.utils import load_resource
|
||||
import datetime
|
||||
import random
|
||||
|
||||
|
||||
checks_json = "resources/describe_trusted_advisor_checks.json"
|
||||
ADVISOR_CHECKS = load_resource(resource_filename(__name__, checks_json))
|
||||
|
||||
|
||||
class SupportCase(object):
|
||||
def __init__(self, **kwargs):
|
||||
self.case_id = kwargs.get("case_id")
|
||||
self.display_id = "foo_display_id"
|
||||
self.subject = kwargs.get("subject")
|
||||
self.status = "opened"
|
||||
self.service_code = kwargs.get("service_code")
|
||||
self.category_code = kwargs.get("category_code")
|
||||
self.severity_code = kwargs.get("severity_code")
|
||||
self.submitted_by = "moto@moto.com"
|
||||
self.time_created = self.get_datetime()
|
||||
self.attachment_set_id = kwargs.get("attachment_set_id")
|
||||
self.communication_body = kwargs.get("communication_body")
|
||||
self.language = kwargs.get("language")
|
||||
self.cc_email_addresses = kwargs.get("cc_email_addresses")
|
||||
self.communications = {
|
||||
"recentCommunications": {
|
||||
"communications": [
|
||||
{
|
||||
"caseId": self.case_id,
|
||||
"body": self.communication_body,
|
||||
"submittedBy": self.submitted_by,
|
||||
"timeCreated": self.get_datetime(),
|
||||
"attachmentSet": [
|
||||
{
|
||||
"attachmentId": self.attachment_set_id,
|
||||
"fileName": "support_file.txt",
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
"nextToken": "foo_next_token",
|
||||
}
|
||||
}
|
||||
|
||||
def get_datetime(self):
|
||||
return str(datetime.datetime.now().isoformat())
|
||||
|
||||
|
||||
class SupportBackend(BaseBackend):
|
||||
def __init__(self, region_name=None):
|
||||
super(SupportBackend, self).__init__()
|
||||
self.region_name = region_name
|
||||
self.check_status = {}
|
||||
self.cases = {}
|
||||
|
||||
def reset(self):
|
||||
region_name = self.region_name
|
||||
@ -58,6 +100,137 @@ class SupportBackend(BaseBackend):
|
||||
elif self.check_status[check_id] == "abandoned":
|
||||
self.check_status[check_id] = "none"
|
||||
|
||||
def advance_case_status(self, case_id):
|
||||
"""
|
||||
Fake an advancement through case statuses
|
||||
"""
|
||||
|
||||
if self.cases[case_id].status == "opened":
|
||||
self.cases[case_id].status = "pending-customer-action"
|
||||
|
||||
elif self.cases[case_id].status == "pending-customer-action":
|
||||
self.cases[case_id].status = "reopened"
|
||||
|
||||
elif self.cases[case_id].status == "reopened":
|
||||
self.cases[case_id].status = "resolved"
|
||||
|
||||
elif self.cases[case_id].status == "resolved":
|
||||
self.cases[case_id].status = "unassigned"
|
||||
|
||||
elif self.cases[case_id].status == "unassigned":
|
||||
self.cases[case_id].status = "work-in-progress"
|
||||
|
||||
elif self.cases[case_id].status == "work-in-progress":
|
||||
self.cases[case_id].status = "opened"
|
||||
|
||||
def advance_case_severity_codes(self, case_id):
|
||||
"""
|
||||
Fake an advancement through case status severities
|
||||
"""
|
||||
if self.cases[case_id].severity_code == "low":
|
||||
self.cases[case_id].severity_code = "normal"
|
||||
|
||||
elif self.cases[case_id].severity_code == "normal":
|
||||
self.cases[case_id].severity_code = "high"
|
||||
|
||||
elif self.cases[case_id].severity_code == "high":
|
||||
self.cases[case_id].severity_code = "urgent"
|
||||
|
||||
elif self.cases[case_id].severity_code == "urgent":
|
||||
self.cases[case_id].severity_code = "critical"
|
||||
|
||||
elif self.cases[case_id].severity_code == "critical":
|
||||
self.cases[case_id].severity_code = "low"
|
||||
|
||||
def resolve_case(self, case_id):
|
||||
self.advance_case_status(case_id)
|
||||
|
||||
resolved_case = {
|
||||
"initialCaseStatus": self.cases[case_id].status,
|
||||
"finalCaseStatus": "resolved",
|
||||
}
|
||||
|
||||
return resolved_case
|
||||
|
||||
# persist case details to self.cases
|
||||
def create_case(
|
||||
self,
|
||||
subject,
|
||||
service_code,
|
||||
severity_code,
|
||||
category_code,
|
||||
communication_body,
|
||||
cc_email_addresses,
|
||||
language,
|
||||
issue_type,
|
||||
attachment_set_id,
|
||||
):
|
||||
# Random case ID
|
||||
random_case_id = "".join(
|
||||
random.choice("0123456789ABCDEFGHIJKLMabcdefghijklm") for i in range(16)
|
||||
)
|
||||
case_id = "case-12345678910-2020-%s" % random_case_id
|
||||
case = SupportCase(
|
||||
case_id=case_id,
|
||||
subject=subject,
|
||||
service_code=service_code,
|
||||
severity_code=severity_code,
|
||||
category_code=category_code,
|
||||
communication_body=communication_body,
|
||||
cc_email_addresses=cc_email_addresses,
|
||||
language=language,
|
||||
attachment_set_id=attachment_set_id,
|
||||
)
|
||||
self.cases[case_id] = case
|
||||
|
||||
return {"caseId": case_id}
|
||||
|
||||
def describe_cases(
|
||||
self,
|
||||
case_id_list,
|
||||
display_id,
|
||||
after_time,
|
||||
before_time,
|
||||
include_resolved_cases,
|
||||
next_token,
|
||||
max_results,
|
||||
language,
|
||||
include_communications,
|
||||
):
|
||||
cases = []
|
||||
|
||||
for case in case_id_list:
|
||||
self.advance_case_status(case)
|
||||
self.advance_case_severity_codes(case)
|
||||
formatted_case = {
|
||||
"caseId": self.cases[case].case_id,
|
||||
"displayId": self.cases[case].display_id,
|
||||
"subject": self.cases[case].subject,
|
||||
"status": self.cases[case].status,
|
||||
"serviceCode": self.cases[case].service_code,
|
||||
"categoryCode": self.cases[case].category_code,
|
||||
"severityCode": self.cases[case].severity_code,
|
||||
"submittedBy": self.cases[case].submitted_by,
|
||||
"timeCreated": self.cases[case].time_created,
|
||||
"ccEmailAddresses": self.cases[case].cc_email_addresses,
|
||||
"language": self.cases[case].language,
|
||||
}
|
||||
|
||||
if include_communications:
|
||||
formatted_case.update(self.cases[case].communications)
|
||||
|
||||
if (
|
||||
include_resolved_cases is False
|
||||
and formatted_case["status"] == "resolved"
|
||||
):
|
||||
continue
|
||||
|
||||
cases.append(formatted_case)
|
||||
case_values = {"cases": cases}
|
||||
case_values.update({"nextToken": next_token})
|
||||
|
||||
return case_values
|
||||
|
||||
|
||||
support_backends = {}
|
||||
|
||||
|
@ -24,3 +24,57 @@ class SupportResponse(BaseResponse):
|
||||
status = self.support_backend.refresh_trusted_advisor_check(check_id=check_id,)
|
||||
|
||||
return json.dumps(status)
|
||||
|
||||
def resolve_case(self):
|
||||
case_id = self._get_param("caseId")
|
||||
resolve_case_response = self.support_backend.resolve_case(case_id=case_id,)
|
||||
return json.dumps(resolve_case_response)
|
||||
|
||||
def create_case(self):
|
||||
subject = self._get_param("subject")
|
||||
service_code = self._get_param("serviceCode")
|
||||
severity_code = self._get_param("severityCode")
|
||||
category_code = self._get_param("categoryCode")
|
||||
communication_body = self._get_param("communicationBody")
|
||||
cc_email_addresses = self._get_param("ccEmailAddresses")
|
||||
language = self._get_param("language")
|
||||
issue_type = self._get_param("issueType")
|
||||
attachment_set_id = self._get_param("attachmentSetId")
|
||||
create_case_response = self.support_backend.create_case(
|
||||
subject=subject,
|
||||
service_code=service_code,
|
||||
severity_code=severity_code,
|
||||
category_code=category_code,
|
||||
communication_body=communication_body,
|
||||
cc_email_addresses=cc_email_addresses,
|
||||
language=language,
|
||||
issue_type=issue_type,
|
||||
attachment_set_id=attachment_set_id,
|
||||
)
|
||||
|
||||
return json.dumps(create_case_response)
|
||||
|
||||
def describe_cases(self):
|
||||
case_id_list = self._get_param("caseIdList")
|
||||
display_id = self._get_param("displayId")
|
||||
after_time = self._get_param("afterTime")
|
||||
before_time = self._get_param("beforeTime")
|
||||
include_resolved_cases = self._get_param("includeResolvedCases", False)
|
||||
next_token = self._get_param("nextToken")
|
||||
max_results = self._get_int_param("maxResults")
|
||||
language = self._get_param("language")
|
||||
include_communications = self._get_param("includeCommunications", True)
|
||||
|
||||
describe_cases_response = self.support_backend.describe_cases(
|
||||
case_id_list=case_id_list,
|
||||
display_id=display_id,
|
||||
after_time=after_time,
|
||||
before_time=before_time,
|
||||
include_resolved_cases=include_resolved_cases,
|
||||
next_token=next_token,
|
||||
max_results=max_results,
|
||||
language=language,
|
||||
include_communications=include_communications,
|
||||
)
|
||||
|
||||
return json.dumps(describe_cases_response)
|
||||
|
@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
from moto import mock_support
|
||||
|
||||
@ -66,46 +67,33 @@ def test_refresh_trusted_advisor_check_returns_an_expected_status():
|
||||
possible_statuses = ["none", "enqueued", "processing", "success", "abandoned"]
|
||||
check_name = "XXXIIIY"
|
||||
response = client.refresh_trusted_advisor_check(checkId=check_name)
|
||||
actual_status = [response["status"]["status"]]
|
||||
set(actual_status).issubset(possible_statuses).should.be.true
|
||||
actual_status = response["status"]["status"]
|
||||
possible_statuses.should.contain(actual_status)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"possible_statuses",
|
||||
[
|
||||
["none", "enqueued", "processing"],
|
||||
["none", "enqueued", "processing", "success", "abandoned"],
|
||||
],
|
||||
)
|
||||
@mock_support
|
||||
def test_refresh_trusted_advisor_check_cycles_to_new_status_on_each_call():
|
||||
"""
|
||||
On each call, the next expected status is returned
|
||||
"""
|
||||
client = boto3.client("support", "us-east-1")
|
||||
check_name = "XXXIIIY"
|
||||
actual_statuses = []
|
||||
possible_statuses = ["none", "enqueued", "processing", "success", "abandoned"]
|
||||
|
||||
for status in possible_statuses:
|
||||
response = client.refresh_trusted_advisor_check(checkId=check_name)
|
||||
actual_statuses.append(response["status"]["status"])
|
||||
|
||||
actual_statuses.should.equal(possible_statuses)
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_refresh_trusted_advisor_check_cycles_to_new_status_on_each_call():
|
||||
def test_refresh_trusted_advisor_check_cycles_to_new_status_on_each_call(
|
||||
possible_statuses,
|
||||
):
|
||||
"""
|
||||
Called only three times, only three expected statuses are returned
|
||||
"""
|
||||
client = boto3.client("support", "us-east-1")
|
||||
check_name = "XXXIIIY"
|
||||
actual_statuses = []
|
||||
possible_statuses = ["none", "enqueued", "processing"]
|
||||
|
||||
for status in possible_statuses:
|
||||
response = client.refresh_trusted_advisor_check(checkId=check_name)
|
||||
actual_statuses.append(response["status"]["status"])
|
||||
|
||||
unexpected_statuses = set(["success", "abandoned"]).issubset(actual_statuses)
|
||||
|
||||
actual_statuses.should.equal(
|
||||
possible_statuses
|
||||
) and unexpected_statuses.should.be.false
|
||||
actual_statuses.should.equal(possible_statuses)
|
||||
|
||||
|
||||
@mock_support
|
||||
@ -118,7 +106,13 @@ def test_refresh_trusted_advisor_check_cycles_to_new_status_on_with_two_checks()
|
||||
check_2_name = "XXXIIIZ"
|
||||
check_1_statuses = []
|
||||
check_2_statuses = []
|
||||
possible_statuses = ["none", "enqueued", "processing", "success", "abandoned"]
|
||||
possible_statuses = [
|
||||
"none",
|
||||
"enqueued",
|
||||
"processing",
|
||||
"success",
|
||||
"abandoned",
|
||||
]
|
||||
|
||||
for check in possible_statuses:
|
||||
response = client.refresh_trusted_advisor_check(checkId=check_1_name)
|
||||
@ -155,3 +149,605 @@ def test_refresh_trusted_advisor_check_cycle_continues_on_full_cycle():
|
||||
expected_none_response = client.refresh_trusted_advisor_check(checkId=check_name)
|
||||
|
||||
expected_none_response["status"]["status"].should.equal("none")
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_case_is_closed():
|
||||
"""
|
||||
On closing a case, the correct resolved response is returned
|
||||
"""
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
case_id = create_case_response["caseId"]
|
||||
|
||||
resolve_case_response = client.resolve_case(caseId=case_id)
|
||||
|
||||
possible_case_status = [
|
||||
"opened",
|
||||
"pending-customer-action",
|
||||
"reopened",
|
||||
"unassigned",
|
||||
"resolved",
|
||||
"work-in-progress",
|
||||
]
|
||||
expected_initial_case = [resolve_case_response["initialCaseStatus"]]
|
||||
expected_final_case = "resolved"
|
||||
|
||||
set(expected_initial_case).issubset(possible_case_status).should.be.true
|
||||
|
||||
expected_final_case.should.equal("resolved")
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_case_created():
|
||||
"""
|
||||
On creating a support request its response contains a case ID
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
len(create_case_response["caseId"]).should.equal(38)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"key,value",
|
||||
[
|
||||
("subject", "test_subject",),
|
||||
("serviceCode", "test_service_code",),
|
||||
("severityCode", "normal",),
|
||||
("categoryCode", "test_category_code",),
|
||||
("language", "test_language",),
|
||||
],
|
||||
)
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described(key, value):
|
||||
"""
|
||||
On creating a support request it can be described
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual_case_id = describe_cases_response["cases"][0][key]
|
||||
|
||||
actual_case_id.should.equal(value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"key,value",
|
||||
[
|
||||
("subject", "test_subject",),
|
||||
("serviceCode", "test_service_code",),
|
||||
("severityCode", "normal",),
|
||||
("categoryCode", "test_category_code",),
|
||||
("language", "test_language",),
|
||||
],
|
||||
)
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_without_next_token(key, value):
|
||||
"""
|
||||
On creating a support request it can be described without next token
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
maxResults=137,
|
||||
)
|
||||
|
||||
actual_case_id = describe_cases_response["cases"][0][key]
|
||||
|
||||
actual_case_id.should.equal(value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"key,value",
|
||||
[
|
||||
("subject", "test_subject",),
|
||||
("serviceCode", "test_service_code",),
|
||||
("severityCode", "normal",),
|
||||
("categoryCode", "test_category_code",),
|
||||
("language", "test_language",),
|
||||
],
|
||||
)
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_without_max_results(key, value):
|
||||
"""
|
||||
On creating a support request it can be described without max_results
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
language="test_lanauage",
|
||||
nextToken="test_next_token",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual_case_id = describe_cases_response["cases"][0][key]
|
||||
|
||||
actual_case_id.should.equal(value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"key,value",
|
||||
[
|
||||
("subject", "test_subject",),
|
||||
("serviceCode", "test_service_code",),
|
||||
("severityCode", "normal",),
|
||||
("categoryCode", "test_category_code",),
|
||||
("language", "test_language",),
|
||||
],
|
||||
)
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_without_max_results_or_next_token(
|
||||
key, value
|
||||
):
|
||||
"""
|
||||
On creating a support request it can be described without max_results
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual_case_id = describe_cases_response["cases"][0][key]
|
||||
|
||||
actual_case_id.should.equal(value)
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_created_case_cc_email_correct():
|
||||
"""
|
||||
On creating a support request it can be described with
|
||||
the correct cc email
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual_case_id = describe_cases_response["cases"][0]["ccEmailAddresses"][0]
|
||||
|
||||
actual_case_id.should.equal("test_email_cc")
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_case_include_resolved_defaults_to_false():
|
||||
"""
|
||||
On creating a support request it can be described and it
|
||||
defaults to not include resolved cases
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
|
||||
for _ in range(3):
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
actual = describe_cases_response["cases"]
|
||||
|
||||
actual.should_not.contain(case_id_list)
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_case_include_communications_defaults_to_true():
|
||||
"""
|
||||
On creating a support request it can be described and it
|
||||
defaults to include communcations cases
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
)
|
||||
|
||||
actual = describe_cases_response["cases"][0]
|
||||
|
||||
actual.should.contain("recentCommunications")
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_multiple_support_created_cases_can_be_described():
|
||||
"""
|
||||
On creating multiple support requests they can be described
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response_1 = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
create_case_response_2 = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = [create_case_response_1["caseId"], create_case_response_2["caseId"]]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=case_id_list,
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual_case_id_1 = describe_cases_response["cases"][0]["caseId"]
|
||||
actual_case_id_2 = describe_cases_response["cases"][1]["caseId"]
|
||||
|
||||
actual_case_id_1.should.equal(case_id_list[0])
|
||||
actual_case_id_2.should.equal(case_id_list[1])
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_and_contains_communications_when_set_to_true():
|
||||
"""
|
||||
On creating a support request it can be described and contains comms
|
||||
when includeResolvedCases=True
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual_recent_comm = describe_cases_response["cases"][0]
|
||||
actual_recent_comm.should.contain("recentCommunications")
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_and_does_not_contain_communications_when_false():
|
||||
"""
|
||||
On creating a support request it does not include
|
||||
comms when includeCommunications=False
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=False,
|
||||
)
|
||||
|
||||
actual_recent_comm = describe_cases_response["cases"][0]
|
||||
|
||||
actual_recent_comm.should_not.contain("recentCommunications")
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_and_contains_resolved_cases_when_true():
|
||||
"""
|
||||
On creating a support request it does contain resolved cases when
|
||||
includeResolvedCases=true
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
|
||||
for _ in range(4):
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual = describe_cases_response["cases"][0]["caseId"]
|
||||
|
||||
actual.should.equal(case_id_list)
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_and_does_not_contain_resolved_cases_when_false():
|
||||
"""
|
||||
On creating a support request it does not contain resolved cases when
|
||||
includeResolvedCases=false
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
|
||||
for _ in range(4):
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=False,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual = describe_cases_response["cases"]
|
||||
actual.should_not.contain(case_id_list)
|
||||
|
||||
|
||||
@mock_support
|
||||
def test_support_created_case_can_be_described_and_can_cycle_case_severities():
|
||||
"""
|
||||
On creating a support request it can be described and cycles case severities
|
||||
"""
|
||||
|
||||
client = boto3.client("support", "us-east-1")
|
||||
create_case_response = client.create_case(
|
||||
subject="test_subject",
|
||||
serviceCode="test_service_code",
|
||||
severityCode="low",
|
||||
categoryCode="test_category_code",
|
||||
communicationBody="test_communication_body",
|
||||
ccEmailAddresses=["test_email_cc",],
|
||||
language="test_language",
|
||||
issueType="test_issue_type",
|
||||
attachmentSetId="test_attachment_set_id",
|
||||
)
|
||||
|
||||
case_id_list = create_case_response["caseId"]
|
||||
|
||||
for _ in range(3):
|
||||
describe_cases_response = client.describe_cases(
|
||||
caseIdList=[case_id_list],
|
||||
displayId="test_display_id",
|
||||
afterTime="test_after_time",
|
||||
beforeTime="test_before_time",
|
||||
includeResolvedCases=True,
|
||||
nextToken="test_next_token",
|
||||
maxResults=137,
|
||||
language="test_lanauage",
|
||||
includeCommunications=True,
|
||||
)
|
||||
|
||||
actual = describe_cases_response["cases"][0]["severityCode"]
|
||||
|
||||
actual.should.equal("urgent")
|
||||
|
Loading…
Reference in New Issue
Block a user