Example #1
0
    def test_create_instance(self):
        testInst = Instance()
        testInst.title = 'Testing'
        testInst.edition = '1st ed'

        self.assertEqual(
            str(testInst),
            '<Instance(title=Testing, edition=1st ed, work=None)>')
Example #2
0
 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'])