  def testListInstances(self, mock_request, mock_provider):
    """Test that instances of an account are correctly listed."""
    mock_provider.return_value = azure_mocks.MOCK_CAPACITY_PROVIDER
    mock_request.return_value = azure_mocks.MOCK_REQUEST_INSTANCES

    # If we don't specify a resource group name, the 'list_all' method should
    # be called.
    instances = azure_mocks.FAKE_ACCOUNT.compute.ListInstances()
    mock_request.assert_called_with(mock.ANY, 'list_all')
    self.assertEqual(1, len(instances))
    self.assertIn('fake-vm-name', instances)
    instance = instances['fake-vm-name']
    self.assertEqual('fake-vm-name', instance.name)
    self.assertEqual(
        '/subscriptions/sub/resourceGroups/fake-resource-group'
        '/providers/Microsoft.Compute/type/fake-vm-name', instance.resource_id)
    self.assertEqual('fake-resource-group', instance.resource_group_name)
    self.assertEqual('fake-region', instance.region)
    self.assertEqual(['fake-zone'], instance.zones)

    # If we specify a resource group name, the 'list' method should be called.
    azure_mocks.FAKE_ACCOUNT.compute.ListInstances(
        resource_group_name=instance.resource_group_name)
    mock_request.assert_called_with(
        mock.ANY, 'list', {'resource_group_name': instance.resource_group_name})
Test that instances of an account are correctly listed.
tests/providers/azure/internal/test_compute.py