def test_constrain_not_called(self): dmm = MockDockerManager() dmm._diff_constraints = mock.Mock(return_value=dict()) dmm.hypervisor = MockHypervisor(dmm) dmm.constrain() assert not dmm.hypervisor.constrain.called
def test_constrain_called(self): diff = dict(cpu_count=0) dmm = MockDockerManager() dmm._diff_constraints = mock.Mock(return_value=diff) dmm.hypervisor = MockHypervisor(dmm) dmm.hypervisor._set_env = mock.Mock() dmm.constrain() assert dmm.hypervisor.constrain.called _, kwargs = dmm.hypervisor.constrain.call_args_list.pop() assert len(kwargs) == len(diff) assert kwargs['cpu_count'] == DEFAULTS['cpu_count'] assert kwargs['memory_size'] == DEFAULTS['memory_size']