Fix resource group get-group-query & update-query-query (#3934)
* Fix resource group get-group-query & update-query-query * Remove list logic * Added tests * Fix tests * Fix update query tests * fix tests
This commit is contained in:
parent
867cf078de
commit
4ad6c3932e
@ -71,6 +71,9 @@ class ResourceGroupsResponse(BaseResponse):
|
|||||||
|
|
||||||
def get_group_query(self):
|
def get_group_query(self):
|
||||||
group_name = self._get_param("GroupName")
|
group_name = self._get_param("GroupName")
|
||||||
|
group_arn = self._get_param("Group")
|
||||||
|
if group_arn and not group_name:
|
||||||
|
group_name = group_arn.split(":")[-1]
|
||||||
group = self.resourcegroups_backend.get_group(group_name=group_name)
|
group = self.resourcegroups_backend.get_group(group_name=group_name)
|
||||||
return json.dumps(
|
return json.dumps(
|
||||||
{
|
{
|
||||||
@ -165,6 +168,9 @@ class ResourceGroupsResponse(BaseResponse):
|
|||||||
def update_group_query(self):
|
def update_group_query(self):
|
||||||
group_name = self._get_param("GroupName")
|
group_name = self._get_param("GroupName")
|
||||||
resource_query = self._get_param("ResourceQuery")
|
resource_query = self._get_param("ResourceQuery")
|
||||||
|
group_arn = self._get_param("Group")
|
||||||
|
if group_arn and not group_name:
|
||||||
|
group_name = group_arn.split(":")[-1]
|
||||||
group = self.resourcegroups_backend.update_group_query(
|
group = self.resourcegroups_backend.update_group_query(
|
||||||
group_name=group_name, resource_query=resource_query
|
group_name=group_name, resource_query=resource_query
|
||||||
)
|
)
|
||||||
|
@ -64,11 +64,18 @@ def test_get_group():
|
|||||||
def test_get_group_query():
|
def test_get_group_query():
|
||||||
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
|
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
|
||||||
|
|
||||||
test_create_group()
|
get_response = test_get_group()
|
||||||
|
|
||||||
response = resource_groups.get_group_query(GroupName="test_resource_group")
|
response = resource_groups.get_group_query(GroupName="test_resource_group")
|
||||||
response["GroupQuery"]["ResourceQuery"]["Type"].should.contain("TAG_FILTERS_1_0")
|
response["GroupQuery"]["ResourceQuery"]["Type"].should.contain("TAG_FILTERS_1_0")
|
||||||
|
|
||||||
|
response_get = resource_groups.get_group_query(
|
||||||
|
Group=get_response.get("Group").get("GroupArn")
|
||||||
|
)
|
||||||
|
response_get["GroupQuery"]["ResourceQuery"]["Type"].should.contain(
|
||||||
|
"TAG_FILTERS_1_0"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_resourcegroups
|
@mock_resourcegroups
|
||||||
def test_get_tags():
|
def test_get_tags():
|
||||||
@ -136,7 +143,7 @@ def test_untag():
|
|||||||
def test_update_group():
|
def test_update_group():
|
||||||
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
|
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
|
||||||
|
|
||||||
test_get_group()
|
get_response = test_get_group()
|
||||||
|
|
||||||
response = resource_groups.update_group(
|
response = resource_groups.update_group(
|
||||||
GroupName="test_resource_group", Description="description_2"
|
GroupName="test_resource_group", Description="description_2"
|
||||||
@ -220,7 +227,7 @@ def test_create_group_with_configuration():
|
|||||||
def test_update_group_query():
|
def test_update_group_query():
|
||||||
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
|
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
|
||||||
|
|
||||||
test_create_group()
|
group_response = test_get_group()
|
||||||
|
|
||||||
response = resource_groups.update_group_query(
|
response = resource_groups.update_group_query(
|
||||||
GroupName="test_resource_group",
|
GroupName="test_resource_group",
|
||||||
@ -245,3 +252,25 @@ def test_update_group_query():
|
|||||||
response["GroupQuery"]["ResourceQuery"]["Type"].should.contain(
|
response["GroupQuery"]["ResourceQuery"]["Type"].should.contain(
|
||||||
"CLOUDFORMATION_STACK_1_0"
|
"CLOUDFORMATION_STACK_1_0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
response = resource_groups.update_group_query(
|
||||||
|
Group=group_response.get("Group").get("GroupArn"),
|
||||||
|
ResourceQuery={
|
||||||
|
"Type": "TAG_FILTERS_1_0",
|
||||||
|
"Query": json.dumps(
|
||||||
|
{
|
||||||
|
"ResourceTypeFilters": ["AWS::AllSupported"],
|
||||||
|
"TagFilters": [
|
||||||
|
{"Key": "resources_tag_key", "Values": ["resources_tag_value"]}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
response["GroupQuery"]["ResourceQuery"]["Type"].should.contain("TAG_FILTERS_1_0")
|
||||||
|
|
||||||
|
response = resource_groups.get_group_query(
|
||||||
|
Group=group_response.get("Group").get("GroupArn")
|
||||||
|
)
|
||||||
|
response["GroupQuery"]["ResourceQuery"]["Type"].should.contain("TAG_FILTERS_1_0")
|
||||||
|
Loading…
Reference in New Issue
Block a user