def test_set_work_fields(self): testInstance = Instance() mock_work = MagicMock() mock_work.importSubjects.return_value = ['subj1', 'subj2'] testInstance.work = mock_work testSubjects = ['subj1', 'subj2'] testInstance.setWorkFields('series', 'pos', testSubjects) self.assertEqual(testInstance.work.series, 'series') self.assertEqual(testInstance.work.series_position, 'pos')
def test_update(self): testData = {'title': 'New Instance'} testInstance = Instance() testInstance.title = 'Old Instance' testInstance.work = MagicMock() with patch.multiple(Instance, setWorkFields=DEFAULT, createTmpRelations=DEFAULT, cleanData=DEFAULT, updateAgents=DEFAULT, addIdentifiers=DEFAULT, updateAltTitles=DEFAULT, updateMeasurements=DEFAULT, updateLinks=DEFAULT, updateDates=DEFAULT, updateRights=DEFAULT, insertLanguages=DEFAULT, insertItems=DEFAULT, removeTmpRelations=DEFAULT) as inst_mocks: inst_mocks['insertItems'].return_value = ['epub'] newEpubs = testInstance.update('session', testData) self.assertEqual(testInstance.title, 'New Instance') self.assertEqual(newEpubs, ['epub'])