Exemplo n.º 1
0
    def test_update_instance(self, mockInst):
        testWork = Work()
        testWork.epubsToLoad = []
        testWork.session = 'session'

        testWork.updateInstance(mockInst, 'newInst')

        mockInst.update.assert_called_once_with('session', 'newInst')
Exemplo n.º 2
0
 def test_work_insert(self):
     testData = {'title': 'Test Title'}
     mock_session = MagicMock()
     testWork = Work(session=mock_session)
     testWork.epubsToLoad = []
     with patch.multiple(Work,
                         createTmpRelations=DEFAULT,
                         addImportJson=DEFAULT,
                         addIdentifiers=DEFAULT,
                         addInstances=DEFAULT,
                         addAgents=DEFAULT,
                         addAltTitles=DEFAULT,
                         addSubjects=DEFAULT,
                         addMeasurements=DEFAULT,
                         addLinks=DEFAULT,
                         addDates=DEFAULT,
                         addLanguages=DEFAULT,
                         removeTmpRelations=DEFAULT) as item_mocks:
         newEpubs = testWork.insert(testData)
         self.assertEqual(testWork.title, 'Test Title')
         self.assertEqual(newEpubs, [])
Exemplo n.º 3
0
 def test_item_update(self):
     testData = {'title': 'Title', 'series': 'newSeries'}
     testWork = Work()
     testWork.title = 'Title'
     testWork.series = 'oldSeries'
     testWork.epubsToLoad = []
     with patch.multiple(Work,
                         createTmpRelations=DEFAULT,
                         addImportJson=DEFAULT,
                         addTitles=DEFAULT,
                         updateIdentifiers=DEFAULT,
                         updateInstances=DEFAULT,
                         updateAgents=DEFAULT,
                         updateSubjects=DEFAULT,
                         updateMeasurements=DEFAULT,
                         updateLinks=DEFAULT,
                         updateDates=DEFAULT,
                         updateLanguages=DEFAULT,
                         removeTmpRelations=DEFAULT) as item_mocks:
         newEpubs = testWork.update(testData)
         self.assertEqual(testWork.series, 'newSeries')
         self.assertEqual(newEpubs, [])