Athena - WorkGroup configuration should be a dictionary, not a string (#6212)

This commit is contained in:
Bert Blommers 2023-04-15 10:02:47 +00:00 committed by GitHub
parent 8c0c688c7b
commit af841303d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -42,7 +42,7 @@ class WorkGroup(TaggableResourceMixin, BaseModel):
self,
athena_backend: "AthenaBackend",
name: str,
configuration: str,
configuration: Dict[str, Any],
description: str,
tags: List[Dict[str, str]],
):
@ -161,7 +161,9 @@ class AthenaBackend(BaseBackend):
self.prepared_statements: Dict[str, PreparedStatement] = {}
# Initialise with the primary workgroup
self.create_work_group("primary", "", "", [])
self.create_work_group(
name="primary", description="", configuration=dict(), tags=[]
)
@staticmethod
def default_vpc_endpoint_service(
@ -175,7 +177,7 @@ class AthenaBackend(BaseBackend):
def create_work_group(
self,
name: str,
configuration: str,
configuration: Dict[str, Any],
description: str,
tags: List[Dict[str, str]],
) -> Optional[WorkGroup]:

View File

@ -12,7 +12,7 @@ from moto.core import DEFAULT_ACCOUNT_ID
def test_create_work_group():
client = boto3.client("athena", region_name="us-east-1")
response = client.create_work_group(
client.create_work_group(
Name="athena_workgroup",
Description="Test work group",
Configuration={
@ -24,12 +24,11 @@ def test_create_work_group():
},
}
},
Tags=[],
)
try:
# The second time should throw an error
response = client.create_work_group(
client.create_work_group(
Name="athena_workgroup",
Description="duplicate",
Configuration={
@ -61,6 +60,16 @@ def test_create_work_group():
work_group["State"].should.equal("ENABLED")
@mock_athena
def test_get_primary_workgroup():
client = boto3.client("athena", region_name="us-east-1")
assert len(client.list_work_groups()["WorkGroups"]) == 1
primary = client.get_work_group(WorkGroup="primary")["WorkGroup"]
assert primary["Name"] == "primary"
assert primary["Configuration"] == {}
@mock_athena
def test_create_and_get_workgroup():
client = boto3.client("athena", region_name="us-east-1")