Exemple #1
0
    def test_add_identifiers(self, mock_unglue, mock_identifier):
        testInst = Instance()
        testInst.tmp_identifiers = [{
            'identifier': 'id1',
            'type': 'test'
        }, {
            'identifier': 'id2',
            'type': 'isbn'
        }]
        mockTestID = MagicMock()
        mockTestID.type = 'test'
        mockTestISBN = MagicMock()
        mockTestISBN.type = 'isbn'
        mockISBNValue = MagicMock()
        mockISBNValue.value = 'testISBN'
        mockTestISBN.isbn = [mockISBNValue]
        mock_identifier.side_effect = [mockTestID, mockTestISBN]

        testInst.addIdentifiers()
        # mock_unglue.assert_called_once_with('testISBN')
        mock_unglue.assert_not_called()  # Temporarily disabled for performance
        mock_identifier.assert_has_calls([
            call(testInst.tmp_identifiers[0]),
            call(testInst.tmp_identifiers[1])
        ])
Exemple #2
0
    def test_add_identifiers(self, mock_identifier):
        testInst = Instance()
        testInst.tmp_identifiers = ['id1', 'id2']

        testInst.addIdentifiers()
        self.assertEqual(len(list(testInst.identifiers)), 2)