# Path: scar/providers/aws/resourcegroups.py
# class ResourceGroups(GenericClient):
#     """Class to manage AWS Resource Groups"""
# 
#     def __init__(self, resources_info) -> None:
#         super().__init__(resources_info.get('lambda'))
# 
#     def get_resource_arn_list(self, iam_user_id: str, resource_type: str = 'lambda') -> List:
#         """Returns a list of ARNs filtered by the resource_type
#         passed and the tags created by scar."""
#         try:
#             # Creation of a function_info filter by tags
#             tag_filters = [{'Key': 'owner', 'Values': [iam_user_id]},
#                            {'Key': 'createdby', 'Values': ['scar']}]
#             resource_type_filters = [resource_type]
#             tagged_resources = self.client.get_tagged_resources(tag_filters, resource_type_filters)
#             return [function_info['ResourceARN'] for function_info in tagged_resources]
#         except ClientError as cerr:
#             logger.error("Error getting function_info arn by tag",
#                          f"Error getting function_info arn by tag: {cerr}")
#             raise cerr


import unittest
import sys
from mock import MagicMock
from mock import patch
from scar.providers.aws.resourcegroups import ResourceGroups
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

sys.path.append("..")
sys.path.append(".")
sys.path.append("../..")



class TestResourceGroups(unittest.TestCase):

    def __init__(self, *args):
        unittest.TestCase.__init__(self, *args)

    def test_init(self):
        rg = ResourceGroups({})
        self.assertEqual(type(rg.client.client).__name__, "ResourceGroupsTaggingAPI")

    @patch('boto3.Session')
    def test_get_resource_arn_list(self, boto_session):
        session = MagicMock(['client'])
        client = MagicMock(['get_resources'])
        session.client.return_value = client
        boto_session.return_value = session

# Path: scar/providers/aws/resourcegroups.py
# class ResourceGroups(GenericClient):
#     """Class to manage AWS Resource Groups"""
# 
#     def __init__(self, resources_info) -> None:
#         super().__init__(resources_info.get('lambda'))
# 
#     def get_resource_arn_list(self, iam_user_id: str, resource_type: str = 'lambda') -> List:
#         """Returns a list of ARNs filtered by the resource_type
#         passed and the tags created by scar."""
#         try:
#             # Creation of a function_info filter by tags
#             tag_filters = [{'Key': 'owner', 'Values': [iam_user_id]},
#                            {'Key': 'createdby', 'Values': ['scar']}]
#             resource_type_filters = [resource_type]
#             tagged_resources = self.client.get_tagged_resources(tag_filters, resource_type_filters)
#             return [function_info['ResourceARN'] for function_info in tagged_resources]
#         except ClientError as cerr:
#             logger.error("Error getting function_info arn by tag",
#                          f"Error getting function_info arn by tag: {cerr}")
#             raise cerr


# Path: test/unit/aws/test_resourcegroups.py
import unittest
import sys
from mock import MagicMock
from mock import patch
from scar.providers.aws.resourcegroups import ResourceGroups

#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

sys.path.append("..")
sys.path.append(".")
sys.path.append("../..")



class TestResourceGroups(unittest.TestCase):

    def __init__(self, *args):
        unittest.TestCase.__init__(self, *args)

    def test_init(self):
        rg = ResourceGroups({})
        self.assertEqual(type(rg.client.client).__name__, "ResourceGroupsTaggingAPI")

    @patch('boto3.Session')
    def test_get_resource_arn_list(self, boto_session):
        session = MagicMock(['client'])
        client = MagicMock(['get_resources'])
        session.client.return_value = client
        boto_session.return_value = session

        rg = ResourceGroups({})