def test_updateInsert_update(self, mock_lookup): mock_work = MagicMock() mock_instance = MagicMock() mock_instance.update.return_value = ['epub'] mock_session = MagicMock() mock_session.query().get.return_value = mock_instance oldInstance = Instance.updateOrInsert(mock_session, {}, mock_work) self.assertEqual(oldInstance, mock_instance) self.assertEqual(mock_work.epubsToLoad[0], 'epub')
def test_updateInsert_insert(self, mock_create, mock_lookup): mock_work = MagicMock() newInstance = Instance.updateOrInsert('session', {}, mock_work) self.assertEqual(newInstance, 'newInstance') self.assertEqual(mock_work.epubsToLoad[0], 'epub')