# Path: libcloudforensics/providers/aws/internal/common.py
# EC2_SERVICE = 'ec2'
# ACCOUNT_SERVICE = 'sts'
# KMS_SERVICE = 'kms'
# CLOUDTRAIL_SERVICE = 'cloudtrail'
# S3_SERVICE = 's3'
# IAM_SERVICE = 'iam'
# INSTANCE = 'instance'
# VOLUME = 'volume'
# SNAPSHOT = 'snapshot'
# UBUNTU_1804_FILTER = 'ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20200611'  # pylint: disable=line-too-long
# ALINUX2_BASE_FILTER = 'amzn2-ami-hvm-2*-x86_64-gp2'
# def CreateTags(resource: str, tags: Dict[str, str]) -> Dict[str, Any]:
# def GetInstanceTypeByCPU(cpu_cores: int) -> str:
# def ExecuteRequest(client: 'botocore.client.EC2',
#                    func: str,
#                    kwargs: Dict[str, Any]) -> List[Dict[str, Any]]:


import typing
import unittest
from libcloudforensics.providers.aws.internal import common
# 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.
"""Tests for aws module - common.py."""




class AWSCommonTest(unittest.TestCase):
  """Test the common.py public methods"""

  @typing.no_type_check
  def testCreateTags(self):
    """Test that tag specifications are correctly created"""
    tag_specifications = common.CreateTags(common.VOLUME, {'Name': 'fake-name'})
    self.assertEqual('volume', tag_specifications['ResourceType'])
    self.assertEqual(1, len(tag_specifications['Tags']))
    self.assertEqual('Name', tag_specifications['Tags'][0]['Key'])
    self.assertEqual('fake-name', tag_specifications['Tags'][0]['Value'])

    tag_specifications = common.CreateTags(
        common.VOLUME, {'Name': 'fake-name', 'FakeTag': 'fake-tag'})
    self.assertEqual(2, len(tag_specifications['Tags']))
    self.assertEqual('FakeTag', tag_specifications['Tags'][1]['Key'])
    self.assertEqual('fake-tag', tag_specifications['Tags'][1]['Value'])

  @typing.no_type_check
  def testGetInstanceTypeByCPU(self):
    """Test that the instance type matches the requested amount of CPU cores."""
    self.assertEqual('m4.large', common.GetInstanceTypeByCPU(2))

# Path: libcloudforensics/providers/aws/internal/common.py
# EC2_SERVICE = 'ec2'
# ACCOUNT_SERVICE = 'sts'
# KMS_SERVICE = 'kms'
# CLOUDTRAIL_SERVICE = 'cloudtrail'
# S3_SERVICE = 's3'
# IAM_SERVICE = 'iam'
# INSTANCE = 'instance'
# VOLUME = 'volume'
# SNAPSHOT = 'snapshot'
# UBUNTU_1804_FILTER = 'ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20200611'  # pylint: disable=line-too-long
# ALINUX2_BASE_FILTER = 'amzn2-ami-hvm-2*-x86_64-gp2'
# def CreateTags(resource: str, tags: Dict[str, str]) -> Dict[str, Any]:
# def GetInstanceTypeByCPU(cpu_cores: int) -> str:
# def ExecuteRequest(client: 'botocore.client.EC2',
#                    func: str,
#                    kwargs: Dict[str, Any]) -> List[Dict[str, Any]]:


# Path: tests/providers/aws/internal/test_common.py
import typing
import unittest
from libcloudforensics.providers.aws.internal import common

# 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.
"""Tests for aws module - common.py."""




class AWSCommonTest(unittest.TestCase):
  """Test the common.py public methods"""

  @typing.no_type_check
  def testCreateTags(self):
    """Test that tag specifications are correctly created"""
    tag_specifications = common.CreateTags(common.VOLUME, {'Name': 'fake-name'})
    self.assertEqual('volume', tag_specifications['ResourceType'])
    self.assertEqual(1, len(tag_specifications['Tags']))
    self.assertEqual('Name', tag_specifications['Tags'][0]['Key'])
    self.assertEqual('fake-name', tag_specifications['Tags'][0]['Value'])

    tag_specifications = common.CreateTags(
        common.VOLUME, {'Name': 'fake-name', 'FakeTag': 'fake-tag'})
    self.assertEqual(2, len(tag_specifications['Tags']))
    self.assertEqual('FakeTag', tag_specifications['Tags'][1]['Key'])
    self.assertEqual('fake-tag', tag_specifications['Tags'][1]['Value'])

  @typing.no_type_check
  def testGetInstanceTypeByCPU(self):
    """Test that the instance type matches the requested amount of CPU cores."""
    self.assertEqual('m4.large', common.GetInstanceTypeByCPU(2))

    self.assertEqual('m4.16xlarge', common.GetInstanceTypeByCPU(64))