moto/tests/test_amp/test_amp_logging_config.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
2.0 KiB
Python
Raw Normal View History

2022-10-23 11:23:23 +00:00
import unittest
import boto3
2022-10-23 11:23:23 +00:00
from moto import mock_amp
@mock_amp
class TestAmpLoggingConfig(unittest.TestCase):
def setUp(self) -> None:
self.client = boto3.client("amp", region_name="us-east-2")
workspace = self.client.create_workspace(alias="test", tags={"t": "v"})
self.workspace_id = workspace["workspaceId"]
def test_describe_logging(self):
resp = self.client.describe_logging_configuration(workspaceId=self.workspace_id)
assert resp["loggingConfiguration"] == {}
2022-10-23 11:23:23 +00:00
def test_create_logging(self):
resp = self.client.create_logging_configuration(
workspaceId=self.workspace_id, logGroupArn="log/arn"
)
assert resp["status"] == {"statusCode": "ACTIVE"}
2022-10-23 11:23:23 +00:00
resp = self.client.describe_logging_configuration(
workspaceId=self.workspace_id
)["loggingConfiguration"]
assert "createdAt" in resp
assert resp["logGroupArn"] == "log/arn"
assert resp["status"] == {"statusCode": "ACTIVE"}
assert resp["workspace"] == self.workspace_id
2022-10-23 11:23:23 +00:00
def test_update_logging(self):
self.client.create_logging_configuration(
workspaceId=self.workspace_id, logGroupArn="log/arn"
)
resp = self.client.update_logging_configuration(
workspaceId=self.workspace_id, logGroupArn="log/arn2"
)
assert resp["status"] == {"statusCode": "ACTIVE"}
2022-10-23 11:23:23 +00:00
resp = self.client.describe_logging_configuration(
workspaceId=self.workspace_id
)["loggingConfiguration"]
assert "modifiedAt" in resp
assert resp["logGroupArn"] == "log/arn2"
2022-10-23 11:23:23 +00:00
def test_delete_logging(self):
resp = self.client.create_logging_configuration(
workspaceId=self.workspace_id, logGroupArn="log/arn"
)
self.client.delete_logging_configuration(workspaceId=self.workspace_id)
resp = self.client.describe_logging_configuration(workspaceId=self.workspace_id)
assert resp["loggingConfiguration"] == {}