def test_updateObject(mExc, mOut, mStore): func = MagicMock() store = MagicMock() mStore.ChuteStorage.return_value = store update = dict(updateClass='CHUTE', updateType='create', name='test', tok=111111, pkg=None, func=func) update = updateObject.parse(update) mExc.executionplan.generatePlans.return_value = False mExc.executionplan.executePlans.return_value = False update.execute() mExc.executionplan.generatePlans.assert_called_once_with(update) mExc.executionplan.aggregatePlans.assert_called_once_with(update) mExc.executionplan.executePlans.assert_called_once_with(update) store.saveChute.assert_called_once_with(update.new) assert mOut.usage.call_count == 1 func.assert_called_once_with(update)
def test_update_object_parse(): """ Test the updateobject parse function. """ from paradrop.backend.fc.updateObject import UpdateChute, parse obj = { 'name': 'Test', 'updateClass': 'CHUTE', 'updateType': 'CREATE', 'tok': 'tok' } # Test creating an UpdateChute object update = parse(obj) assert isinstance(update, UpdateChute) # Test an unrecognized type obj['updateClass'] = "FAIL" assert_raises(Exception, parse, obj)