def test_validate_with_source_uri_file(self):
     # source given in form of uri, source_share parsed from uri, source and dest account are the same
     ns = self._create_namespace(source_uri='https://storage_name.file.core.windows.net/share2',
                                 destination_share='share1')
     get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertEqual(ns.source_share, 'share2')
     self.assertIsNone(ns.source_client)
Example #2
0
 def test_validate_with_source_uri_file(self):
     # source given in form of uri, source_share parsed from uri, source and dest account are the same
     ns = self._create_namespace(source_uri='https://storage_name.file.core.windows.net/share2',
                                 destination_share='share1')
     get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertEqual(ns.source_share, 'share2')
     self.assertIsNone(ns.source_client)
 def test_validate_with_different_source_uri_sas_file(self):
     # source given in form of uri, source_share parsed from uri, source and dest account are different
     ns = self._create_namespace(source_uri='https://other_name.file.core.windows.net/share2?some_sas_token',
                                 destination_share='share1')
     get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertEqual(ns.source_share, 'share2')
     self.assertIsNotNone(ns.source_client)
     self.assertEqual(ns.source_client.account_name, 'other_name')
 def test_validate_with_source_uri_file(self):
     # source given in form of uri, source_share parsed from uri, source and dest account are the same
     ns = self._create_namespace(source_uri='https://storage_name.file.core.windows.net/share2',
                                 destination_share='share1')
     with mock.patch('azure.cli.command_modules.storage._validators._query_account_key', return_value="fake_key"):
         get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertEqual(ns.source_share, 'share2')
     self.assertIsNone(ns.source_client)
Example #5
0
 def test_validate_with_different_source_uri_sas_file(self):
     # source given in form of uri, source_share parsed from uri, source and dest account are different
     ns = self._create_namespace(source_uri='https://other_name.file.core.windows.net/share2?some_sas_token',
                                 destination_share='share1')
     get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertEqual(ns.source_share, 'share2')
     self.assertIsNotNone(ns.source_client)
     self.assertEqual(ns.source_client.account_name, 'other_name')
Example #6
0
 def test_validate_with_source_uri_file(self):
     # source given in form of uri, source_share parsed from uri, source and dest account are the same
     ns = self._create_namespace(source_uri='https://storage_name.file.core.windows.net/share2',
                                 destination_share='share1')
     with mock.patch('azure.cli.command_modules.storage._validators._query_account_key', return_value="fake_key"):
         get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertEqual(ns.source_share, 'share2')
     self.assertIsNone(ns.source_client)
 def test_validate_with_source_uri_blob(self):
     # source given in form of uri, source_container parsed from uri, source and dest account are the same
     ns = self._create_namespace(
         source_uri='https://storage_name.blob.core.windows.net/container2',
         destination_container='container1')
     get_source_file_or_blob_service_client(ns)
     self.assertEqual(ns.source_container, 'container2')
     self.assertIsNone(ns.source_client)
 def test_validate_with_different_source_uri_sas_blob(self):
     # source given in form of uri, source_container parsed from uri, source and dest account are different
     ns = self._create_namespace(
         source_uri=
         'https://other_name.blob.core.windows.net/container2?some_sas_token',
         destination_container='container1')
     get_source_file_or_blob_service_client(ns)
     self.assertEqual(ns.source_container, 'container2')
     self.assertIsNotNone(ns.source_client)
     self.assertEqual(ns.source_client.account_name, 'other_name')
    def test_validate_negatives(self):
        # bad argument combinations
        with self.assertRaises(ValueError):
            get_source_file_or_blob_service_client(
                MockCmd(self.cli),
                self._create_namespace(source_uri='https://storage_name.file.core.windows.net/share2',
                                       source_account_name='some_name'))

        with self.assertRaises(ValueError):
            get_source_file_or_blob_service_client(MockCmd(self.cli), self._create_namespace(source_uri='faulty_uri'))

        with self.assertRaises(ValueError):
            get_source_file_or_blob_service_client(
                MockCmd(self.cli),
                self._create_namespace(source_container='container_name', source_share='share_name'))
Example #10
0
    def test_validate_negatives(self):
        # bad argument combinations
        with self.assertRaises(ValueError):
            get_source_file_or_blob_service_client(
                MockCmd(self.cli),
                self._create_namespace(source_uri='https://storage_name.file.core.windows.net/share2',
                                       source_account_name='some_name'))

        with self.assertRaises(ValueError):
            get_source_file_or_blob_service_client(MockCmd(self.cli), self._create_namespace(source_uri='faulty_uri'))

        with self.assertRaises(ValueError):
            get_source_file_or_blob_service_client(
                MockCmd(self.cli),
                self._create_namespace(source_container='container_name', source_share='share_name'))
Example #11
0
 def test_validate_with_share_name_file(self):
     # source share name given, validator does not change namespace aside from ensuring source-client none
     ns = self._create_namespace(source_share='share2',
                                 destination_share='share1')
     get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertIsNone(ns.source_client)
 def test_validate_with_share_name_file(self):
     # source share name given, validator does not change namespace aside from ensuring source-client none
     ns = self._create_namespace(source_share='share2', destination_share='share1')
     get_source_file_or_blob_service_client(MockCmd(self.cli), ns)
     self.assertIsNone(ns.source_client)
 def test_validate_with_container_name_blob(self):
     # source container name given, validator does not change namespace aside from ensuring source-client none
     ns = self._create_namespace(source_container='container2',
                                 destination_container='container1')
     get_source_file_or_blob_service_client(ns)
     self.assertIsNone(ns.source_client)