Skip to content

Commit

Permalink
{Compute} Fix tests of VM image (Azure#30417)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanzhudd authored Dec 3, 2024
1 parent 978b94c commit 22fa655
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from azure.cli.core.cloud import CloudEndpointNotSetException
from azure.cli.core.mock import DummyCli
from azure.cli.testsdk import LiveScenarioTest

from knack.util import CLIError

Expand All @@ -26,7 +27,7 @@ def _get_test_cmd():
return cmd


class TestVMImage(unittest.TestCase):
class VMImageLiveScenarioTest(LiveScenarioTest):

def test_read_images_from_alias_doc(self):
from azure.cli.command_modules.vm.azure_stack.custom import list_vm_images
Expand All @@ -48,6 +49,8 @@ def test_read_images_from_alias_doc(self):
self.assertEqual(parts[2], ubuntu_image['sku'])
self.assertEqual(parts[3], ubuntu_image['version'])


class TestVMImage(unittest.TestCase):
@mock.patch('azure.cli.core.cloud.get_active_cloud', autospec=True)
def test_when_alias_doc_is_missing(self, mock_get_active_cloud):
from azure.cli.command_modules.vm.azure_stack._actions import load_images_from_aliases_doc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from azure.cli.core.cloud import CloudEndpointNotSetException
from azure.cli.core.mock import DummyCli
from azure.cli.testsdk import LiveScenarioTest

from knack.util import CLIError

Expand All @@ -26,7 +27,7 @@ def _get_test_cmd():
return cmd


class TestVMImage(unittest.TestCase):
class VMImageLiveScenarioTest(LiveScenarioTest):

def test_read_images_from_alias_doc(self):
from azure.cli.command_modules.vm.azure_stack.custom import list_vm_images
Expand All @@ -48,6 +49,8 @@ def test_read_images_from_alias_doc(self):
self.assertEqual(parts[2], ubuntu_image['sku'])
self.assertEqual(parts[3], ubuntu_image['version'])


class TestVMImage(unittest.TestCase):
@mock.patch('azure.cli.core.cloud.get_active_cloud', autospec=True)
def test_when_alias_doc_is_missing(self, mock_get_active_cloud):
from azure.cli.command_modules.vm.azure_stack._actions import load_images_from_aliases_doc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from azure.cli.core.cloud import CloudEndpointNotSetException
from azure.cli.core.mock import DummyCli
from azure.cli.testsdk import LiveScenarioTest

from knack.util import CLIError

Expand All @@ -26,7 +27,7 @@ def _get_test_cmd():
return cmd


class TestVMImage(unittest.TestCase):
class VMImageLiveScenarioTest(LiveScenarioTest):

def test_read_images_from_alias_doc(self):
from azure.cli.command_modules.vm.azure_stack.custom import list_vm_images
Expand All @@ -48,6 +49,8 @@ def test_read_images_from_alias_doc(self):
self.assertEqual(parts[2], ubuntu_image['sku'])
self.assertEqual(parts[3], ubuntu_image['version'])


class TestVMImage(unittest.TestCase):
@mock.patch('azure.cli.core.cloud.get_active_cloud', autospec=True)
def test_when_alias_doc_is_missing(self, mock_get_active_cloud):
from azure.cli.command_modules.vm.azure_stack._actions import load_images_from_aliases_doc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from azure.cli.core.cloud import CloudEndpointNotSetException
from azure.cli.core.mock import DummyCli
from azure.cli.testsdk import LiveScenarioTest

from knack.util import CLIError

Expand All @@ -26,7 +27,7 @@ def _get_test_cmd():
return cmd


class TestVMImage(unittest.TestCase):
class VMImageLiveScenarioTest(LiveScenarioTest):

def test_read_images_from_alias_doc(self):
from azure.cli.command_modules.vm.custom import list_vm_images
Expand All @@ -48,6 +49,8 @@ def test_read_images_from_alias_doc(self):
self.assertEqual(parts[2], ubuntu_image['sku'])
self.assertEqual(parts[3], ubuntu_image['version'])


class TestVMImage(unittest.TestCase):
@mock.patch('azure.cli.core.cloud.get_active_cloud', autospec=True)
def test_when_alias_doc_is_missing(self, mock_get_active_cloud):
from azure.cli.command_modules.vm._actions import load_images_from_aliases_doc
Expand Down

0 comments on commit 22fa655

Please sign in to comment.