Esempio n. 1
0
class TestTagService(TestCase):
    def setUp(self):
        self.tags_service = TagService()

    def test_try_find_tag_list_is_none(self):
        tags_list = None
        tag_key = "SomeKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list, tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_keys_returns_none(self):
        tags_list = None
        tag_key = "SomeKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list, tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_keys_returns_empty_dict(self):
        tags_list = {}
        tag_key = "SomeKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list, tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_key_not_found(self):
        tags_list = {"NotMyKey": "Val1"}
        tag_key = "MyKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list, tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_returns_key_value(self):
        tags_list = {"MyKey": "Val1"}
        # tags_list.keys = Mock(return_value={"MyKey" : "Val1"})
        tag_key = "MyKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list, tag_key=tag_key)
        self.assertEquals(tag_value, "Val1")
    def setUp(self):
        self.logger = Mock()
        self.storage_service = MagicMock()
        self.vm_service = VirtualMachineService(MagicMock())
        self.network_service = NetworkService(MagicMock(), MagicMock())
        self.vm_credentials_service = Mock()
        self.key_pair_service = Mock()
        self.security_group_service = MagicMock()
        self.tags_service = TagService()
        self.name_provider_service = MagicMock()
        self.vm_extension_service = MagicMock()
        self.generic_lock_provider = MagicMock()
        self.cancellation_service = MagicMock()
        self.image_data_factory = MagicMock()
        self.vm_details_provider = MagicMock()

        self.deploy_operation = DeployAzureVMOperation(
            vm_service=self.vm_service,
            network_service=self.network_service,
            storage_service=self.storage_service,
            vm_credentials_service=self.vm_credentials_service,
            key_pair_service=self.key_pair_service,
            tags_service=self.tags_service,
            security_group_service=self.security_group_service,
            name_provider_service=self.name_provider_service,
            vm_extension_service=self.vm_extension_service,
            generic_lock_provider=self.generic_lock_provider,
            cancellation_service=self.cancellation_service,
            image_data_factory=self.image_data_factory,
            vm_details_provider=self.vm_details_provider)
Esempio n. 3
0
    def setUp(self):
        self.storage_service = MagicMock()
        self.cancellation_service = MagicMock()
        self.task_waiter_service = MagicMock()
        self.vm_service = MagicMock()
        self.network_service = MagicMock()
        self.tag_service = TagService()
        self.key_pair_service = KeyPairService(
            storage_service=self.storage_service)
        self.security_group_service = SecurityGroupService(
            self.network_service)
        self.logger = MagicMock()
        self.cryptography_service = CryptographyService()
        self.name_provider_service = MagicMock()
        self.resource_id_parser = MagicMock()

        self.prepare_connectivity_operation = PrepareSandboxInfraOperation(
            vm_service=self.vm_service,
            network_service=self.network_service,
            storage_service=self.storage_service,
            tags_service=self.tag_service,
            key_pair_service=self.key_pair_service,
            security_group_service=self.security_group_service,
            cryptography_service=self.cryptography_service,
            name_provider_service=self.name_provider_service,
            subnet_locker=Lock(),
            cancellation_service=self.cancellation_service,
            resource_id_parser=self.resource_id_parser)
Esempio n. 4
0
class TestTagService(TestCase):
    def setUp(self):
        self.tags_service = TagService()

    def test_try_find_tag_list_is_none(self):
        tags_list = None
        tag_key = "SomeKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list,
                                                   tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_keys_returns_none(self):
        tags_list = None
        tag_key = "SomeKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list,
                                                   tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_keys_returns_empty_dict(self):
        tags_list = {}
        tag_key = "SomeKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list,
                                                   tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_key_not_found(self):
        tags_list = {"NotMyKey": "Val1"}
        tag_key = "MyKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list,
                                                   tag_key=tag_key)
        self.assertIsNone(tag_value)

    def test_try_find_tag_returns_key_value(self):
        tags_list = {"MyKey": "Val1"}
        # tags_list.keys = Mock(return_value={"MyKey" : "Val1"})
        tag_key = "MyKey"
        tag_value = self.tags_service.try_find_tag(tags_list=tags_list,
                                                   tag_key=tag_key)
        self.assertEquals(tag_value, "Val1")
 def setUp(self):
     self.logger = Mock()
     self.vm_service = VirtualMachineService(MagicMock())
     self.network_service = NetworkService(MagicMock(), MagicMock())
     self.tags_service = TagService()
     self.storage_service = MagicMock()
     self.security_group_service = SecurityGroupService(
         self.network_service)
     self.generic_lock_provider = Mock()
     self.generic_lock_provider.get_resource_lock = Mock(
         return_value=Mock())
     self.delete_operation = DeleteAzureVMOperation(
         vm_service=self.vm_service,
         network_service=self.network_service,
         tags_service=self.tags_service,
         security_group_service=self.security_group_service,
         storage_service=self.storage_service,
         generic_lock_provider=self.generic_lock_provider,
         subnet_locker=Lock())
Esempio n. 6
0
 def setUp(self):
     self.tags_service = TagService()
Esempio n. 7
0
    def __init__(self):
        self.cancellation_service = CommandCancellationService()
        waiter_service = TaskWaiterService(
            cancellation_service=self.cancellation_service)
        self.command_result_parser = CommandResultsParser()
        self.model_parser = AzureModelsParser()
        self.resource_id_parser = AzureResourceIdParser()
        self.ip_service = IpService()
        self.tags_service = TagService()
        self.network_service = NetworkService(self.ip_service,
                                              self.tags_service)
        self.storage_service = StorageService(
            cancellation_service=self.cancellation_service)
        self.vm_credentials_service = VMCredentialsService()
        self.key_pair_service = KeyPairService(
            storage_service=self.storage_service)
        self.security_group_service = SecurityGroupService(
            self.network_service)
        self.vm_custom_params_extractor = VmCustomParamsExtractor()
        self.cryptography_service = CryptographyService()
        self.name_provider_service = NameProviderService()
        self.vm_extension_service = VMExtensionService(URLHelper(),
                                                       waiter_service)
        self.subscription_service = SubscriptionService()
        self.task_waiter_service = waiter_service
        self.vm_service = VirtualMachineService(
            task_waiter_service=self.task_waiter_service)
        self.generic_lock_provider = GenericLockProvider()
        self.subnet_locker = Lock()
        self.vm_details_provider = VmDetailsProvider(self.network_service,
                                                     self.resource_id_parser)
        self.image_data_factory = ImageDataFactory(vm_service=self.vm_service)

        self.autoload_operation = AutoloadOperation(
            subscription_service=self.subscription_service,
            vm_service=self.vm_service,
            network_service=self.network_service)

        self.access_key_operation = AccessKeyOperation(
            key_pair_service=self.key_pair_service,
            storage_service=self.storage_service)

        self.prepare_connectivity_operation = PrepareSandboxInfraOperation(
            vm_service=self.vm_service,
            network_service=self.network_service,
            storage_service=self.storage_service,
            tags_service=self.tags_service,
            key_pair_service=self.key_pair_service,
            security_group_service=self.security_group_service,
            cryptography_service=self.cryptography_service,
            name_provider_service=self.name_provider_service,
            cancellation_service=self.cancellation_service,
            subnet_locker=self.subnet_locker,
            resource_id_parser=self.resource_id_parser)

        self.deploy_azure_vm_operation = DeployAzureVMOperation(
            vm_service=self.vm_service,
            network_service=self.network_service,
            storage_service=self.storage_service,
            key_pair_service=self.key_pair_service,
            tags_service=self.tags_service,
            vm_credentials_service=self.vm_credentials_service,
            security_group_service=self.security_group_service,
            name_provider_service=self.name_provider_service,
            vm_extension_service=self.vm_extension_service,
            cancellation_service=self.cancellation_service,
            generic_lock_provider=self.generic_lock_provider,
            image_data_factory=self.image_data_factory,
            vm_details_provider=self.vm_details_provider)

        self.power_vm_operation = PowerAzureVMOperation(
            vm_service=self.vm_service,
            vm_custom_params_extractor=self.vm_custom_params_extractor)

        self.refresh_ip_operation = RefreshIPOperation(
            vm_service=self.vm_service,
            resource_id_parser=self.resource_id_parser)

        self.delete_azure_vm_operation = DeleteAzureVMOperation(
            vm_service=self.vm_service,
            network_service=self.network_service,
            tags_service=self.tags_service,
            security_group_service=self.security_group_service,
            storage_service=self.storage_service,
            generic_lock_provider=self.generic_lock_provider,
            subnet_locker=self.subnet_locker)

        self.deployed_app_ports_operation = DeployedAppPortsOperation(
            vm_custom_params_extractor=self.vm_custom_params_extractor)

        self.vm_details_operation = VmDetailsOperation(
            vm_service=self.vm_service,
            vm_details_provider=self.vm_details_provider)
Esempio n. 8
0
 def setUp(self):
     self.tags_service = TagService()