def test_get_image_or_die_with_valid_spec(self):
     self.assertEqual(
         ImageReference(publisher='Canonical', offer='UbuntuServer', sku='16.04-LTS'),
         _get_image_reference('Canonical:UbuntuServer:16.04-LTS:', None))
     self.assertEqual(
         ImageReference(publisher='Canonical', offer='UbuntuServer', sku='16.04-LTS', version='latest'),
         _get_image_reference('Canonical:UbuntuServer:16.04-LTS:latest', None))
 def test_get_image_or_die_supported_aliases(self):
     self.assertEqual(
         ImageReference(publisher='Canonical', offer='UbuntuServer', sku='16.04-LTS'),
         _get_image_reference('ubuntults', None))
     self.assertEqual(
         ImageReference(publisher='microsoft-ads', offer='linux-data-science-vm-ubuntu', sku='linuxdsvmubuntu'),
         _get_image_reference('ubuntudsvm', None))
 def test_get_image_or_die_with_invalid_spec(self):
     with self.assertRaisesRegexp(CLIError, "--image must have format"):
         _get_image_reference('Canonical:UbuntuServer:16.04-LTS', None)
     with self.assertRaisesRegexp(CLIError, "--image must have format"):
         _get_image_reference('Canonical:UbuntuServer:16.04-LTS:latest:', None)
     with self.assertRaisesRegexp(CLIError, "Image publisher must be provided in --image argument"):
         _get_image_reference(':UbuntuServer:16.04-LTS:latest', None)
     with self.assertRaisesRegexp(CLIError, "Image offer must be provided in --image argument"):
         _get_image_reference('Canonical::16.04-LTS:latest', None)
     with self.assertRaisesRegexp(CLIError, "Image sku must be provided in --image argument"):
         _get_image_reference('Canonical:Offer::latest', None)
 def test_get_image_or_die_with_custom_image_with_version(self):
     self.assertEqual(
         ImageReference(
             publisher='Canonical',
             offer='UbuntuServer',
             sku='16.04-LTS',
             version='latest',
             virtual_machine_image_id='/subscriptions/00/resourceGroups/gr/providers/Microsoft.Compute/images/img'
         ),
         _get_image_reference(
             'Canonical:UbuntuServer:16.04-LTS:latest',
             '/subscriptions/00/resourceGroups/gr/providers/Microsoft.Compute/images/img'),
     )
 def test_get_image_or_die_with_custom_image_without_version(self):
     # noinspection PyTypeChecker
     self.assertEqual(
         ImageReference(
             publisher='Canonical',
             offer='UbuntuServer',
             sku='16.04-LTS',
             version=None,
             virtual_machine_image_id='/subscriptions/00/resourceGroups/gr/providers/Microsoft.Compute/images/img'
         ),
         _get_image_reference(
             'ubuntults', '/subscriptions/00/resourceGroups/gr/providers/Microsoft.Compute/images/img')
     )
 def test_get_image_or_die_with_custom_image_but_without_image(self):
     with self.assertRaisesRegexp(CLIError, 'You need to specify --image argument'):
         _get_image_reference(
             None, '/subscriptions/00/resourceGroups/gr/providers/Microsoft.Compute/images/img')
 def test_get_image_or_die_with_invalid_custom_image(self):
     with self.assertRaisesRegexp(CLIError, 'Ill-formed custom image resource id'):
         _get_image_reference('ubuntults', 'bla-bla')
 def test_get_image_or_die_unsupported_alias(self):
     with self.assertRaisesRegexp(CLIError, 'Unsupported image alias "ubuntu", supported aliases are'):
         _get_image_reference('ubuntu', None)