зеркало из https://github.com/microsoft/azure-cli.git
Verify multi-NIC order. (#3266)
This commit is contained in:
Родитель
70ffc84ab5
Коммит
047d00e9b9
|
@ -57,8 +57,6 @@
|
|||
<Compile Include="azure-cli-core\azure\cli\core\sdk\__init__.py" />
|
||||
<Compile Include="azure-cli-core\azure\cli\core\sdk\__init__.py" />
|
||||
<Compile Include="azure-cli-core\azure\cli\core\telemetry_upload.py" />
|
||||
<Compile Include="azure-cli-core\azure\cli\core\test_utils\vcr_test_base.py" />
|
||||
<Compile Include="azure-cli-core\azure\cli\core\test_utils\__init__.py" />
|
||||
<Compile Include="azure-cli-core\azure\cli\core\_config.py" />
|
||||
<Compile Include="azure-cli-core\azure\cli\core\_debug.py" />
|
||||
<Compile Include="azure-cli-core\azure\cli\core\_environment.py" />
|
||||
|
@ -99,11 +97,13 @@
|
|||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\base.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\checkers.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\const.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\decorators.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\exceptions.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\patches.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\preparers.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\recording_processors.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\utilities.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\vcr_test_base.py" />
|
||||
<Compile Include="azure-cli-testsdk\azure\cli\testsdk\__init__.py" />
|
||||
<Compile Include="azure-cli-testsdk\setup.py" />
|
||||
<Compile Include="azure-cli\azure\cli\command_modules\__init__.py" />
|
||||
|
@ -664,7 +664,6 @@
|
|||
<Folder Include="azure-cli-core\azure\cli\core\extensions\" />
|
||||
<Folder Include="azure-cli-core\azure\cli\core\profiles\" />
|
||||
<Folder Include="azure-cli-core\azure\cli\core\sdk\" />
|
||||
<Folder Include="azure-cli-core\azure\cli\core\test_utils\" />
|
||||
<Folder Include="azure-cli-core\tests\" />
|
||||
<Folder Include="azure-cli-core\tests\__pycache__\" />
|
||||
<Folder Include="azure-cli-nspkg\" />
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
import unittest
|
||||
try:
|
||||
import unittest.mock as mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
from azure.cli.core.application import APPLICATION, Configuration
|
||||
|
||||
|
@ -21,6 +25,40 @@ def mock_echo_args(command_name, parameters):
|
|||
command_table[command_name].handler = prefunc
|
||||
|
||||
|
||||
class TestVMValidators(unittest.TestCase):
|
||||
|
||||
def _mock_get_subscription_id():
|
||||
return '00000000-0000-0000-0000-000000000000'
|
||||
|
||||
@mock.patch('azure.cli.core.commands.client_factory.get_subscription_id', _mock_get_subscription_id)
|
||||
def test_vm_nics(self):
|
||||
|
||||
from argparse import Namespace
|
||||
from azure.cli.command_modules.vm._validators import _validate_vm_create_nics
|
||||
|
||||
for i in range(0, 100):
|
||||
ns = Namespace()
|
||||
ns.resource_group_name = 'rg'
|
||||
ns.nics = ['nic1', 'nic2']
|
||||
_validate_vm_create_nics(ns)
|
||||
|
||||
nic1_expected = {
|
||||
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic1",
|
||||
"properties": {
|
||||
"primary": True
|
||||
}
|
||||
}
|
||||
|
||||
nic2_expected = {
|
||||
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic2",
|
||||
"properties": {
|
||||
"primary": False
|
||||
}
|
||||
}
|
||||
self.assertEqual(ns.nics[0], nic1_expected)
|
||||
self.assertEqual(ns.nics[1], nic2_expected)
|
||||
|
||||
|
||||
class Test_ArgumentParser(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
|
Загрузка…
Ссылка в новой задаче