Esempio n. 1
0
 def test_get_connected_hosts_none(self):
     with mock.patch.object(self.session, '_call_method') as _call_method:
         hosts = ds_util.get_connected_hosts(self.session, 'fake_datastore')
         self.assertEqual([], hosts)
         _call_method.assert_called_once_with(mock.ANY,
                                              'get_object_property',
                                              'fake_datastore', 'host')
Esempio n. 2
0
 def test_get_connected_hosts_none(self):
     with mock.patch.object(self.session,
                            '_call_method') as _call_method:
         hosts = ds_util.get_connected_hosts(self.session,
                                             'fake_datastore')
         self.assertEqual([], hosts)
         _call_method.assert_called_once_with(
                 mock.ANY, 'get_object_property',
                 'fake_datastore', 'host')
Esempio n. 3
0
    def test_get_connected_hosts(self):
        host = mock.Mock(spec=object)
        host.value = 'fake-host'
        host_mount = mock.Mock(spec=object)
        host_mount.key = host
        host_mounts = mock.Mock(spec=object)
        host_mounts.DatastoreHostMount = [host_mount]

        with mock.patch.object(self.session, '_call_method',
                               return_value=host_mounts) as _call_method:
            hosts = ds_util.get_connected_hosts(self.session,
                                                'fake_datastore')
            self.assertEqual(['fake-host'], hosts)
            _call_method.assert_called_once_with(
                    mock.ANY, 'get_object_property',
                    'fake_datastore', 'host')
Esempio n. 4
0
    def test_get_connected_hosts(self):
        host = fake.ManagedObjectReference(value='fake-host',
                                           name='HostSystem')
        host_mount = mock.Mock(spec=object)
        host_mount.key = host
        host_mounts = mock.Mock(spec=object)
        host_mounts.DatastoreHostMount = [host_mount]

        with mock.patch.object(self.session,
                               '_call_method',
                               return_value=host_mounts) as _call_method:
            hosts = ds_util.get_connected_hosts(self.session, 'fake_datastore')
            self.assertEqual(['fake-host'], hosts)
            _call_method.assert_called_once_with(mock.ANY,
                                                 'get_object_property',
                                                 'fake_datastore', 'host')