feature/refresh_trusted_advisor_check (#3705)

* Support - added refresh_trusted_advisor_check
- Returns a random check status
- Returns the check id in the response
- Testing for these two functionalities

* test_support - addressed PR comments, to cycle through a faked number of
check status responses
This commit is contained in:
Connor 2021-02-18 19:32:06 +00:00 committed by GitHub
commit e61d794cbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 152 additions and 0 deletions

View file

@ -13,6 +13,7 @@ class SupportBackend(BaseBackend):
def __init__(self, region_name=None):
super(SupportBackend, self).__init__()
self.region_name = region_name
self.check_status = {}
def reset(self):
region_name = self.region_name
@ -24,6 +25,39 @@ class SupportBackend(BaseBackend):
checks = ADVISOR_CHECKS["checks"]
return checks
def refresh_trusted_advisor_check(self, check_id):
self.advance_check_status(check_id)
status = {
"status": {
"checkId": check_id,
"status": self.check_status[check_id],
"millisUntilNextRefreshable": 123,
}
}
return status
def advance_check_status(self, check_id):
"""
Fake an advancement through statuses on refreshing TA checks
"""
if check_id not in self.check_status:
self.check_status[check_id] = "none"
elif self.check_status[check_id] == "none":
self.check_status[check_id] = "enqueued"
elif self.check_status[check_id] == "enqueued":
self.check_status[check_id] = "processing"
elif self.check_status[check_id] == "processing":
self.check_status[check_id] = "success"
elif self.check_status[check_id] == "success":
self.check_status[check_id] = "abandoned"
elif self.check_status[check_id] == "abandoned":
self.check_status[check_id] = "none"
support_backends = {}