def test_citationFetch_three_authors_work2(self, mockUtils, testApp, mocker):
        mockDB = mocker.MagicMock()
        mockDBClient = mocker.patch('api.blueprints.drbCitation.DBClient')
        mockDBClient.return_value = mockDB

        editionMocks = [mocker.MagicMock(publication_date=date(2022, 1, 1), publishers=[{'name': 'NYPL'}], \
                        edition_statement = '2nd edition.', \
                        measurements = [{'type': 'government_document', 'value': '0'}])]

        mockDB.fetchSingleWork.return_value = mocker.MagicMock(title='testTitle', authors = [{'name': 'testLastName, testFirstName'}, \
                                            {'name': 'testLastName2, testFirstName2'}, \
                                            {'name': 'testLastName3, testFirstName3'}], \
                                            editions = editionMocks)           
            
        mockUtils['formatResponseObject'].return_value\
                = 'citationResponse'

        with testApp.test_request_context('/?format=mla'):
            testAPIResponse = citationFetch('testUUID')

            assert testAPIResponse == 'citationResponse'
            mockDBClient.assert_called_once_with('testDBClient')

            mockUtils['normalizeQueryParams'].assert_called_once()

            mockUtils['formatResponseObject'].assert_called_once_with(
                200, 'citation', {'mla': ' '.join('testLastName, testFirstName, et al. \
                                testTitle. 2nd edition., \
                                NYPL, 2022.'.split())}
                )
    def test_citationFetch_post1900_gov_success(self, mockUtils, testApp, mocker):
            mockDB = mocker.MagicMock()
            mockDBClient = mocker.patch('api.blueprints.drbCitation.DBClient')
            mockDBClient.return_value = mockDB

            editionMocks = [mocker.MagicMock(publication_date=date(2022, 1, 1), publishers=[{'name': 'NYPL'}], \
                            measurements = [{'type': 'government_document', 'value': '1'}])]

            mockDB.fetchSingleWork.return_value = mocker.MagicMock(title='State of the Union Address', \
                                                authors=[{'name': 'United States. Test Agency'}], \
                                                editions = editionMocks) \
                                                
            
            mockUtils['formatResponseObject'].return_value\
                = 'citationResponse'

            with testApp.test_request_context('/?format=mla'):
                testAPIResponse = citationFetch('testUUID')

                assert testAPIResponse == 'citationResponse'
                mockDBClient.assert_called_once_with('testDBClient')

                mockUtils['normalizeQueryParams'].assert_called_once()

                mockUtils['formatResponseObject'].assert_called_once_with(
                    200, 'citation', {'mla': ' '.join('United States, Test Agency. State of the Union Address. \
                                    NYPL, 2022.'.split())}
                )
    def test_citationFetch__two_authors_work(self, mockUtils, testApp, mocker):
        mockDB = mocker.MagicMock()
        mockDBClient = mocker.patch('api.blueprints.drbCitation.DBClient')
        mockDBClient.return_value = mockDB

        editionMocks = [mocker.MagicMock(publication_date=date(1800, 1, 1), publication_place='testPubPlace', \
                        measurements = [{'type': 'government_document', 'value': '0'}])]

        mockDB.fetchSingleWork.return_value = mocker.MagicMock(title='testTitle', \
                                            authors = [{'name': 'testLastName, testFirstName'}, \
                                            {'name': 'testLastName2, testFirstName2'}], \
                                            contributors = [{'roles': 'editor', 'name': 'editLastName, editFirstName'}], \
                                            editions = editionMocks) 
                                                
            
        mockUtils['formatResponseObject'].return_value\
                = 'citationResponse'

        with testApp.test_request_context('/?format=mla'):
            testAPIResponse = citationFetch('testUUID')

            assert testAPIResponse == 'citationResponse'
            mockDBClient.assert_called_once_with('testDBClient')

            mockUtils['normalizeQueryParams'].assert_called_once()

            mockUtils['formatResponseObject'].assert_called_once_with(
                200, 'citation', {'mla': ' '.join('testLastName, testFirstName, and testFirstName2 testLastName2. \
                                testTitle, edited by editFirstName editLastName, \
                                testPubPlace, 1800.'.split())}
                )
    def test_citationFetch_single_edit_work_success(self, mockUtils, testApp, mocker):
        mockDB = mocker.MagicMock()
        mockDBClient = mocker.patch('api.blueprints.drbCitation.DBClient')
        mockDBClient.return_value = mockDB

        editionMocks = [mocker.MagicMock(publication_date=date(1800, 1, 1), publication_place='testPubPlace', \
                        edition_statement = None, measurements = [{'type': 'government_document', 'value': '0'}])]

        mockDB.fetchSingleWork.return_value = mocker.MagicMock(title='testTitle', \
                                            editions = editionMocks) 
                                                
        mockUtils['formatResponseObject'].return_value\
                = 'citationResponse'

        with testApp.test_request_context('/?format=mla'):
            testAPIResponse = citationFetch('testUUID')

            assert testAPIResponse == 'citationResponse'
            mockDBClient.assert_called_once_with('testDBClient')

            mockUtils['normalizeQueryParams'].assert_called_once()

            mockUtils['formatResponseObject'].assert_called_once_with(
                200, 'citation', {'mla': ' '.join('testTitle. \
                                testPubPlace, 1800.'.split())}
                )
    def test_citationFetch_fail2(self, mockUtils, testApp, mocker):
        mockDB = mocker.MagicMock()
        mockDBClient = mocker.patch('api.blueprints.drbCitation.DBClient')
        mockDBClient.return_value = mockDB

        mockUtils['formatResponseObject'].return_value = '400Response'

        with testApp.test_request_context('/?format='):
            testAPIResponse = citationFetch('testUUID')

            assert testAPIResponse == '400Response'
            mockDBClient.assert_called_once_with('testDBClient')

            mockUtils['normalizeQueryParams'].assert_called_once()
            mockUtils['formatResponseObject'].assert_called_once_with(
                400,
                'pageNotFound',
                {'message': 'Need to specify citation format'}
            )
    def test_citationFetch_fail(self, mockUtils, testApp, mocker):
        mockDB = mocker.MagicMock()
        mockDBClient = mocker.patch('api.blueprints.drbCitation.DBClient')
        mockDBClient.return_value = mockDB

        mockDB.fetchSingleWork.return_value = None

        mockUtils['formatResponseObject'].return_value = '404Response'

        with testApp.test_request_context('testUUID/?format=mla'):
            testAPIResponse = citationFetch('testUUID')

            assert testAPIResponse == '404Response'
            mockDBClient.assert_called_once_with('testDBClient')

            mockUtils['normalizeQueryParams'].assert_called_once()
            mockUtils['formatResponseObject'].assert_called_once_with(
                404,
                'citation',
                {'message': 'Unable to locate work with UUID testUUID'}
            )
    def test_citationFetch_bible_post1900_success(self, mockUtils, testApp, mocker):
            mockDB = mocker.MagicMock()
            mockDBClient = mocker.patch('api.blueprints.drbCitation.DBClient')
            mockDBClient.return_value = mockDB

            editionMocks = [mocker.MagicMock(publication_date=date(2022, 1, 1), publishers=[{'name': 'NYPL'}])]

            mockDB.fetchSingleWork.return_value = mocker.MagicMock(title='The Bible', editions=editionMocks)
            
            mockUtils['formatResponseObject'].return_value\
                = 'citationResponse'

            with testApp.test_request_context('/?format=mla'):
                testAPIResponse = citationFetch('testUUID')

                assert testAPIResponse == 'citationResponse'
                mockDBClient.assert_called_once_with('testDBClient')

                mockUtils['normalizeQueryParams'].assert_called_once()

                mockUtils['formatResponseObject'].assert_called_once_with(
                    200, 'citation', {'mla': 'The Bible. Unknown version, NYPL, 2022.'}
                )