def test_add_instances(self, mock_create): testWork = Work() testWork.tmp_instances = ['inst1', 'inst2'] mock_inst = MagicMock() mock_inst.name = 'testInstance' mock_create.side_effect = [(mock_inst, []), (mock_inst, [])] testWork.addInstances() self.assertEqual(list(testWork.instances)[0].name, 'testInstance')
def test_update_instances(self, updateInstance, addInstance, getLocalInstanceIdentifiers, matchLocalInstance, addNewIdentifiers): testWork = Work() testWork.tmp_instances = ['inst1', 'inst2'] existingInst = MagicMock() matchLocalInstance.side_effect = [None, existingInst] getLocalInstanceIdentifiers.return_value = {} addInstance.return_value = 'newInstance' testWork.updateInstances() getLocalInstanceIdentifiers.assert_called_once() updateInstance.assert_called_once_with(existingInst, 'inst2') addInstance.assert_called_once_with('inst1') addNewIdentifiers.assert_has_calls( [call('newInstance', {}), call(existingInst, {})])
def test_update_instances(self, mock_update): testWork = Work() testWork.tmp_instances = ['inst1'] testWork.updateInstances() mock_update.called_once_with('inst1')