def test_get_hypervisor(self, xhyve_instance, hyperv_instance, *_): def reset(): xhyve_instance.called = False hyperv_instance.called = False dmm = MockDockerManager() with mock.patch('golem.docker.manager.is_windows', return_value=True): assert dmm._select_hypervisor() assert hyperv_instance.called assert not xhyve_instance.called reset() with mock.patch('golem.docker.manager.is_windows', return_value=False): with mock.patch('golem.docker.manager.is_osx', return_value=True): assert dmm._select_hypervisor() assert not hyperv_instance.called assert xhyve_instance.called reset() with mock.patch('golem.docker.manager.is_windows', return_value=False): with mock.patch('golem.docker.manager.is_osx', return_value=False): assert not dmm._select_hypervisor() assert not hyperv_instance.called assert not xhyve_instance.called
def test_update_config(self): status_switch = [True] def status_cb(): if status_switch[0]: status_switch[0] = False return True else: return status_switch[0] def done_cb(_): pass config = ConfigMock(0, 768) dmm = MockDockerManager() dmm.pull_images = mock.Mock() dmm.build_images = mock.Mock() hypervisor = mock.Mock() hypervisor.constraints.return_value = DEFAULTS dmm._select_hypervisor = mock.Mock(return_value=hypervisor) with mock.patch.object(dmm, 'command'): dmm.build_config(config) dmm.check_environment() dmm.update_config(status_cb, done_cb, in_background=False, work_dir=None) dmm.update_config(status_cb, done_cb, in_background=True, work_dir=None)