From 3b802702a1dbcc63880d9c16dd20410ce747ca72 Mon Sep 17 00:00:00 2001 From: zhoxing Date: Wed, 8 Dec 2021 11:13:03 +0800 Subject: [PATCH] Refine test_read_images_from_alias_doc --- .../vm/tests/hybrid_2018_03_01/aliases.json | 84 ------------------- .../tests/hybrid_2018_03_01/test_vm_image.py | 12 +-- .../vm/tests/hybrid_2019_03_01/aliases.json | 84 ------------------- .../tests/hybrid_2019_03_01/test_vm_image.py | 12 +-- .../vm/tests/hybrid_2020_09_01/aliases.json | 84 ------------------- .../tests/hybrid_2020_09_01/test_vm_image.py | 12 +-- .../vm/tests/latest/aliases.json | 84 ------------------- .../vm/tests/latest/test_vm_image.py | 12 +-- 8 files changed, 8 insertions(+), 376 deletions(-) delete mode 100644 src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/aliases.json delete mode 100644 src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/aliases.json delete mode 100644 src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/aliases.json delete mode 100644 src/azure-cli/azure/cli/command_modules/vm/tests/latest/aliases.json diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/aliases.json b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/aliases.json deleted file mode 100644 index 4a403e4922b..00000000000 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/aliases.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", - "contentVersion":"1.0.0.0", - "parameters":{}, - "variables":{}, - "resources":[], - - "outputs":{ - "aliases":{ - "metadata":{ - "description":"This list of aliases is used by Azure XPLAT CLI, Azure Powershell, and Azure Portal as shorthands for commonly used VM images. If you change this file, please verify that this doesn't break VMSS creation from Portal :)." - }, - "type":"object", - "value":{ - - "Linux":{ - "CentOS":{ - "publisher":"OpenLogic", - "offer":"CentOS", - "sku":"7.2", - "version":"latest" - }, - "Debian":{ - "publisher":"credativ", - "offer":"Debian", - "sku":"8", - "version":"latest" - }, - "Flatcar": { - "publisher": "kinvolk", - "offer": "flatcar-container-linux-free", - "sku": "stable", - "version": "latest" - }, - "openSUSE":{ - "publisher":"SUSE", - "offer":"openSUSE", - "sku":"13.2", - "version":"latest" - }, - "RHEL":{ - "publisher":"RedHat", - "offer":"RHEL", - "sku":"7.2", - "version":"latest" - }, - "SLES":{ - "publisher":"SUSE", - "offer":"SLES", - "sku":"12-SP1", - "version":"latest" - }, - "UbuntuLTS":{ - "publisher":"Canonical", - "offer":"UbuntuServer", - "sku":"14.04.4-LTS", - "version":"latest" - } - }, - - "Windows":{ - "Win2012R2Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-R2-Datacenter", - "version":"latest" - }, - "Win2012Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-Datacenter", - "version":"latest" - }, - "Win2008R2SP1":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2008-R2-SP1", - "version":"latest" - } - } - } - } - } -} diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/test_vm_image.py b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/test_vm_image.py index 5a661d85440..52fa98b6950 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/test_vm_image.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2018_03_01/test_vm_image.py @@ -27,18 +27,10 @@ def _get_test_cmd(): class TestVMImage(unittest.TestCase): - @mock.patch('azure.cli.command_modules.vm.custom.urlopen', autospec=True) - def test_read_images_from_alias_doc(self, mock_urlopen): + + def test_read_images_from_alias_doc(self): from azure.cli.command_modules.vm.custom import list_vm_images cmd = _get_test_cmd() - file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'aliases.json') - with open(file_path, 'r') as test_file: - test_data = test_file.read().encode() - - mock_read = mock.MagicMock() - mock_read.read.return_value = test_data - mock_urlopen.return_value = mock_read # action images = list_vm_images(cmd) diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/aliases.json b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/aliases.json deleted file mode 100644 index 4a403e4922b..00000000000 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/aliases.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", - "contentVersion":"1.0.0.0", - "parameters":{}, - "variables":{}, - "resources":[], - - "outputs":{ - "aliases":{ - "metadata":{ - "description":"This list of aliases is used by Azure XPLAT CLI, Azure Powershell, and Azure Portal as shorthands for commonly used VM images. If you change this file, please verify that this doesn't break VMSS creation from Portal :)." - }, - "type":"object", - "value":{ - - "Linux":{ - "CentOS":{ - "publisher":"OpenLogic", - "offer":"CentOS", - "sku":"7.2", - "version":"latest" - }, - "Debian":{ - "publisher":"credativ", - "offer":"Debian", - "sku":"8", - "version":"latest" - }, - "Flatcar": { - "publisher": "kinvolk", - "offer": "flatcar-container-linux-free", - "sku": "stable", - "version": "latest" - }, - "openSUSE":{ - "publisher":"SUSE", - "offer":"openSUSE", - "sku":"13.2", - "version":"latest" - }, - "RHEL":{ - "publisher":"RedHat", - "offer":"RHEL", - "sku":"7.2", - "version":"latest" - }, - "SLES":{ - "publisher":"SUSE", - "offer":"SLES", - "sku":"12-SP1", - "version":"latest" - }, - "UbuntuLTS":{ - "publisher":"Canonical", - "offer":"UbuntuServer", - "sku":"14.04.4-LTS", - "version":"latest" - } - }, - - "Windows":{ - "Win2012R2Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-R2-Datacenter", - "version":"latest" - }, - "Win2012Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-Datacenter", - "version":"latest" - }, - "Win2008R2SP1":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2008-R2-SP1", - "version":"latest" - } - } - } - } - } -} diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/test_vm_image.py b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/test_vm_image.py index 5a661d85440..52fa98b6950 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/test_vm_image.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2019_03_01/test_vm_image.py @@ -27,18 +27,10 @@ def _get_test_cmd(): class TestVMImage(unittest.TestCase): - @mock.patch('azure.cli.command_modules.vm.custom.urlopen', autospec=True) - def test_read_images_from_alias_doc(self, mock_urlopen): + + def test_read_images_from_alias_doc(self): from azure.cli.command_modules.vm.custom import list_vm_images cmd = _get_test_cmd() - file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'aliases.json') - with open(file_path, 'r') as test_file: - test_data = test_file.read().encode() - - mock_read = mock.MagicMock() - mock_read.read.return_value = test_data - mock_urlopen.return_value = mock_read # action images = list_vm_images(cmd) diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/aliases.json b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/aliases.json deleted file mode 100644 index 4a403e4922b..00000000000 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/aliases.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", - "contentVersion":"1.0.0.0", - "parameters":{}, - "variables":{}, - "resources":[], - - "outputs":{ - "aliases":{ - "metadata":{ - "description":"This list of aliases is used by Azure XPLAT CLI, Azure Powershell, and Azure Portal as shorthands for commonly used VM images. If you change this file, please verify that this doesn't break VMSS creation from Portal :)." - }, - "type":"object", - "value":{ - - "Linux":{ - "CentOS":{ - "publisher":"OpenLogic", - "offer":"CentOS", - "sku":"7.2", - "version":"latest" - }, - "Debian":{ - "publisher":"credativ", - "offer":"Debian", - "sku":"8", - "version":"latest" - }, - "Flatcar": { - "publisher": "kinvolk", - "offer": "flatcar-container-linux-free", - "sku": "stable", - "version": "latest" - }, - "openSUSE":{ - "publisher":"SUSE", - "offer":"openSUSE", - "sku":"13.2", - "version":"latest" - }, - "RHEL":{ - "publisher":"RedHat", - "offer":"RHEL", - "sku":"7.2", - "version":"latest" - }, - "SLES":{ - "publisher":"SUSE", - "offer":"SLES", - "sku":"12-SP1", - "version":"latest" - }, - "UbuntuLTS":{ - "publisher":"Canonical", - "offer":"UbuntuServer", - "sku":"14.04.4-LTS", - "version":"latest" - } - }, - - "Windows":{ - "Win2012R2Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-R2-Datacenter", - "version":"latest" - }, - "Win2012Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-Datacenter", - "version":"latest" - }, - "Win2008R2SP1":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2008-R2-SP1", - "version":"latest" - } - } - } - } - } -} diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/test_vm_image.py b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/test_vm_image.py index 5a661d85440..52fa98b6950 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/test_vm_image.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/hybrid_2020_09_01/test_vm_image.py @@ -27,18 +27,10 @@ def _get_test_cmd(): class TestVMImage(unittest.TestCase): - @mock.patch('azure.cli.command_modules.vm.custom.urlopen', autospec=True) - def test_read_images_from_alias_doc(self, mock_urlopen): + + def test_read_images_from_alias_doc(self): from azure.cli.command_modules.vm.custom import list_vm_images cmd = _get_test_cmd() - file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'aliases.json') - with open(file_path, 'r') as test_file: - test_data = test_file.read().encode() - - mock_read = mock.MagicMock() - mock_read.read.return_value = test_data - mock_urlopen.return_value = mock_read # action images = list_vm_images(cmd) diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/aliases.json b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/aliases.json deleted file mode 100644 index 4a403e4922b..00000000000 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/aliases.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", - "contentVersion":"1.0.0.0", - "parameters":{}, - "variables":{}, - "resources":[], - - "outputs":{ - "aliases":{ - "metadata":{ - "description":"This list of aliases is used by Azure XPLAT CLI, Azure Powershell, and Azure Portal as shorthands for commonly used VM images. If you change this file, please verify that this doesn't break VMSS creation from Portal :)." - }, - "type":"object", - "value":{ - - "Linux":{ - "CentOS":{ - "publisher":"OpenLogic", - "offer":"CentOS", - "sku":"7.2", - "version":"latest" - }, - "Debian":{ - "publisher":"credativ", - "offer":"Debian", - "sku":"8", - "version":"latest" - }, - "Flatcar": { - "publisher": "kinvolk", - "offer": "flatcar-container-linux-free", - "sku": "stable", - "version": "latest" - }, - "openSUSE":{ - "publisher":"SUSE", - "offer":"openSUSE", - "sku":"13.2", - "version":"latest" - }, - "RHEL":{ - "publisher":"RedHat", - "offer":"RHEL", - "sku":"7.2", - "version":"latest" - }, - "SLES":{ - "publisher":"SUSE", - "offer":"SLES", - "sku":"12-SP1", - "version":"latest" - }, - "UbuntuLTS":{ - "publisher":"Canonical", - "offer":"UbuntuServer", - "sku":"14.04.4-LTS", - "version":"latest" - } - }, - - "Windows":{ - "Win2012R2Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-R2-Datacenter", - "version":"latest" - }, - "Win2012Datacenter":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2012-Datacenter", - "version":"latest" - }, - "Win2008R2SP1":{ - "publisher":"MicrosoftWindowsServer", - "offer":"WindowsServer", - "sku":"2008-R2-SP1", - "version":"latest" - } - } - } - } - } -} diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_image.py b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_image.py index 5a661d85440..52fa98b6950 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_image.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_image.py @@ -27,18 +27,10 @@ def _get_test_cmd(): class TestVMImage(unittest.TestCase): - @mock.patch('azure.cli.command_modules.vm.custom.urlopen', autospec=True) - def test_read_images_from_alias_doc(self, mock_urlopen): + + def test_read_images_from_alias_doc(self): from azure.cli.command_modules.vm.custom import list_vm_images cmd = _get_test_cmd() - file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'aliases.json') - with open(file_path, 'r') as test_file: - test_data = test_file.read().encode() - - mock_read = mock.MagicMock() - mock_read.read.return_value = test_data - mock_urlopen.return_value = mock_read # action images = list_vm_images(cmd)