Added describe_create_account_status to organizations

This commit is contained in:
Stephen Muss 2019-11-06 20:43:21 +11:00
parent b19abbc63e
commit a6255f9801
4 changed files with 42 additions and 2 deletions

View File

@ -4723,7 +4723,7 @@
- [ ] update_server_engine_attributes
## organizations
41% implemented
43% implemented
- [ ] accept_handshake
- [X] attach_policy
- [ ] cancel_handshake
@ -4737,7 +4737,7 @@
- [ ] delete_organizational_unit
- [ ] delete_policy
- [X] describe_account
- [ ] describe_create_account_status
- [X] describe_create_account_status
- [ ] describe_handshake
- [X] describe_organization
- [X] describe_organizational_unit

View File

@ -269,10 +269,32 @@ class OrganizationsBackend(BaseBackend):
)
return account
def get_account_by_attr(self, attr, value):
account = next(
(
account
for account in self.accounts
if hasattr(account, attr) and getattr(account, attr) == value
),
None,
)
if account is None:
raise RESTError(
"AccountNotFoundException",
"You specified an account that doesn't exist.",
)
return account
def describe_account(self, **kwargs):
account = self.get_account_by_id(kwargs["AccountId"])
return account.describe()
def describe_create_account_status(self, **kwargs):
account = self.get_account_by_attr(
"create_account_status_id", kwargs["CreateAccountRequestId"]
)
return account.create_account_status
def list_accounts(self):
return dict(
Accounts=[account.describe()["Account"] for account in self.accounts]

View File

@ -65,6 +65,13 @@ class OrganizationsResponse(BaseResponse):
self.organizations_backend.describe_account(**self.request_params)
)
def describe_create_account_status(self):
return json.dumps(
self.organizations_backend.describe_create_account_status(
**self.request_params
)
)
def list_accounts(self):
return json.dumps(self.organizations_backend.list_accounts())

View File

@ -159,6 +159,17 @@ def test_create_account():
create_status["AccountName"].should.equal(mockname)
@mock_organizations
def test_describe_create_account_status():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")["Organization"]
request_id = client.create_account(AccountName=mockname, Email=mockemail)[
"CreateAccountStatus"
]["Id"]
response = client.describe_create_account_status(CreateAccountRequestId=request_id)
validate_create_account_status(response["CreateAccountStatus"])
@mock_organizations
def test_describe_account():
client = boto3.client("organizations", region_name="us-east-1")