def testRetryOnServiceUnavailableFailsAfter3Times(self):
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)

        answers = [(SERVICE_UNAVAILABLE, ''), (SERVICE_UNAVAILABLE, ''),
                   (SERVICE_UNAVAILABLE, ''), (HTTP_OK, SUCCES_RESPONSE)]
        datas = []

        def sendDataToRemote(data):
            answer = answers.pop(0)
            datas.append(data)
            return answer

        uploader._sendDataToRemote = sendDataToRemote
        exception = None
        try:
            uploader._sendData(1, "HOW IS EVERYTHING")
            self.fail()
        except Exception as e:
            exception = e

        self.assertFalse(exception == None)
        self.assertEqual('uploadId: "1", message: "HTTP 503: "',
                         str(exception))
        self.assertEqual(1, len(answers))
        self.assertEqual(3, len(datas))
        self.assertEqual(3, len(eventLogger.calledMethods))
    def testParseMessage(self):
        SRU_MESSAGE=parse(StringIO(SUCCES_RESPONSE))

        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        version, operationStatus, diagnostics = uploader._parseMessage(SRU_MESSAGE)
        self.assertEquals("1.0", version)
        self.assertEquals("success", operationStatus)
        self.assertEquals(None, diagnostics)
    def testParseMessage(self):
        SRU_MESSAGE = _parse(SUCCES_RESPONSE)

        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        version, operationStatus, diagnostics = uploader._parseMessage(
            SRU_MESSAGE)
        self.assertEqual("1.0", version)
        self.assertEqual("success", operationStatus)
        self.assertEqual(None, diagnostics)
class SruUpdateUploaderTest(SeecrTestCase):
    def setUp(self):
        SeecrTestCase.setUp(self)
        self.target = CallTrace('SruUpdateTarget', verbose=True)
        self.uploader = SruUpdateUploader(self.target, CallTrace('eventlogger'))
        self.sentData = []
        def sendData(anId, data):
            self.sentData.append(data)
        self.uploader._sendData = sendData

        self.upload = CallTrace('Upload')
        self.upload.id = 'some:id'
        self.upload.parts={
            'meta': '<meta>....</meta>',
            'otherdata': '<stupidXML>abcdefgh'
        }

    def testOne(self):
        self.uploader.send(self.upload)
        self.assertEquals(1, len(self.sentData))

        updateRequest = XML(self.sentData[0])
        self.assertEquals('some:id', xpathFirst(updateRequest, 'ucp:recordIdentifier/text()'))
        self.assertEquals('info:srw/action/1/replace', xpathFirst(updateRequest, 'ucp:action/text()'))
        documentParts = xpath(updateRequest, 'srw:record/srw:recordData/document:document/document:part')
        self.assertEquals(2, len(documentParts))

        self.uploader.delete(self.upload)
        updateRequest = XML(self.sentData[1])
        self.assertEquals('some:id', xpathFirst(updateRequest, 'ucp:recordIdentifier/text()'))
        self.assertEquals('info:srw/action/1/delete', xpathFirst(updateRequest, 'ucp:action/text()'))

    def testException(self):
        possibleSRUError="""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/1</diag:uri>
            <diag:details>Traceback (most recent call last): File "../meresco/components/sru/srurecordupdate.py", line 47, in handleRequest File "../meresco/framework/transaction.py", line 63, in unknown File "../meresco/framework/observable.py", line 101, in __call__ File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 106, in _callonce KeyError: '__id__' </diag:details>
            <diag:message>Invalid component: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        uploader._sendDataToRemote = lambda data: (HTTP_OK, possibleSRUError)
        try:
            uploader.send(self.upload)
            self.fail()
        except InvalidComponentException, e:
            self.assertEquals(self.upload.id, e.uploadId)
    def testRetryOnServiceUnavailable(self):
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)

        answers = [(HTTP_OK, SUCCES_RESPONSE)]
        datas = []

        def sendDataToRemote(data):
            answer = answers.pop(0)
            datas.append(data)
            return answer

        uploader._sendDataToRemote = sendDataToRemote
        uploader._sendData(1, b"HOW IS EVERYTHING")

        self.assertEqual(0, len(answers))
        self.assertEqual(1, len(datas))

        answers = [(SERVICE_UNAVAILABLE, ''), (HTTP_OK, SUCCES_RESPONSE)]
        datas = []
        uploader._sendData(1, b"HOW IS EVERYTHING")

        self.assertEqual(0, len(answers))
        self.assertEqual(2, len(datas))
        self.assertEqual(1, len(eventLogger.calledMethods))
        self.assertEqual(
            "Status 503, SERVICE_UNAVAILABLE received while trying to upload",
            eventLogger.calledMethods[0].args[0])
    def setUp(self):
        SeecrTestCase.setUp(self)
        self.target = CallTrace('SruUpdateTarget', verbose=True)
        self.uploader = SruUpdateUploader(self.target,
                                          CallTrace('eventlogger'))
        self.sentData = []

        def sendData(anId, data):
            self.sentData.append(data)

        self.uploader._sendData = sendData

        self.upload = CallTrace('Upload')
        self.upload.id = 'some:id'
        self.upload.parts = {
            'meta': '<meta>....</meta>',
            'otherdata': '<stupidXML>ßabcdefgh'
        }
    def testRetryOnServiceUnavailableFailsAfter3Times(self):
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)

        answers = [(SERVICE_UNAVAILABLE, ''), (SERVICE_UNAVAILABLE, ''), (SERVICE_UNAVAILABLE, ''), (HTTP_OK, SUCCES_RESPONSE)]
        datas = []
        def sendDataToRemote(data):
            answer = answers.pop(0)
            datas.append(data)
            return answer

        uploader._sendDataToRemote = sendDataToRemote
        exception = None
        try:
            uploader._sendData(1, "HOW IS EVERYTHING")
            self.fail()
        except Exception, e:
            exception = e
    def testParseMessageWithDiagnostic(self):
        SRU_MESSAGE=parse(StringIO("""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/12</diag:uri>
            <diag:details>Xsd Validation error</diag:details>
            <diag:message>Invalid component: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""))

        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        version, operationStatus, diagnostics = uploader._parseMessage(SRU_MESSAGE)
        self.assertEquals("1.0", version)
        self.assertEquals("fail", operationStatus)
        self.assertEquals(("info:srw/diagnostic/12/12", "Xsd Validation error", "Invalid component: record rejected"), diagnostics)
    def testException(self):
        possibleSRUError = b"""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/1</diag:uri>
            <diag:details>Traceback (most recent call last): File "../meresco/components/sru/srurecordupdate.py", line 47, in handleRequest File "../meresco/framework/transaction.py", line 63, in unknown File "../meresco/framework/observable.py", line 101, in __call__ File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 106, in _callonce KeyError: '__id__' </diag:details>
            <diag:message>Invalid component: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        uploader._sendDataToRemote = lambda data: (HTTP_OK, possibleSRUError)
        try:
            uploader.send(self.upload)
            self.fail()
        except InvalidComponentException as e:
            self.assertEqual(self.upload.id, e.uploadId)
    def testInvalidDataException(self):
        possibleSRUValidationError="""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/12</diag:uri>
            <diag:details>Xsd Validation error</diag:details>
            <diag:message>Invalid data structure: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        uploader._sendDataToRemote = lambda data: (HTTP_OK, possibleSRUValidationError)
        try:
            uploader.send(self.upload)
            self.fail("Diagnostic code 12 should raise a validation exception")
        except InvalidDataException, e:
            self.assertEquals(self.upload.id, e.uploadId)
    def testException(self):
        possibleSRUError="""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/1</diag:uri>
            <diag:details>Traceback (most recent call last): File "../meresco/components/sru/srurecordupdate.py", line 47, in handleRequest File "../meresco/framework/transaction.py", line 63, in unknown File "../meresco/framework/observable.py", line 101, in __call__ File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 106, in _callonce KeyError: '__id__' </diag:details>
            <diag:message>Invalid component: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        uploader._sendDataToRemote = lambda data: (HTTP_OK, possibleSRUError)
        try:
            uploader.send(self.upload)
            self.fail()
        except InvalidComponentException, e:
            self.assertEquals(self.upload.id, e.uploadId)
    def testRetryOnServiceUnavailable(self):
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)

        answers = [(HTTP_OK, SUCCES_RESPONSE)]
        datas = []
        def sendDataToRemote(data):
            answer = answers.pop(0)
            datas.append(data)
            return answer

        uploader._sendDataToRemote = sendDataToRemote
        uploader._sendData(1, "HOW IS EVERYTHING")

        self.assertEquals(0, len(answers))
        self.assertEquals(1, len(datas))

        answers = [(SERVICE_UNAVAILABLE, ''), (HTTP_OK, SUCCES_RESPONSE)]
        datas = []
        uploader._sendData(1, "HOW IS EVERYTHING")

        self.assertEquals(0, len(answers))
        self.assertEquals(2, len(datas))
        self.assertEquals(1, len(eventLogger.calledMethods))
        self.assertEquals("Status 503, SERVICE_UNAVAILABLE received while trying to upload", eventLogger.calledMethods[0].args[0])
    def testParseMessageWithDiagnostic(self):
        SRU_MESSAGE = _parse("""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/12</diag:uri>
            <diag:details>Xsd Validation error</diag:details>
            <diag:message>Invalid component: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>""")

        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        version, operationStatus, diagnostics = uploader._parseMessage(
            SRU_MESSAGE)
        self.assertEqual("1.0", version)
        self.assertEqual("fail", operationStatus)
        self.assertEqual(("info:srw/diagnostic/12/12", "Xsd Validation error",
                          "Invalid component: record rejected"), diagnostics)
    def testInvalidDataException(self):
        possibleSRUValidationError = b"""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/12</diag:uri>
            <diag:details>Xsd Validation error</diag:details>
            <diag:message>Invalid data structure: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        uploader._sendDataToRemote = lambda data: (HTTP_OK,
                                                   possibleSRUValidationError)
        try:
            uploader.send(self.upload)
            self.fail("Diagnostic code 12 should raise a validation exception")
        except InvalidDataException as e:
            self.assertEqual(self.upload.id, e.uploadId)
    def setUp(self):
        SeecrTestCase.setUp(self)
        self.target = CallTrace('SruUpdateTarget', verbose=True)
        self.uploader = SruUpdateUploader(self.target, CallTrace('eventlogger'))
        self.sentData = []
        def sendData(anId, data):
            self.sentData.append(data)
        self.uploader._sendData = sendData

        self.upload = CallTrace('Upload')
        self.upload.id = 'some:id'
        self.upload.parts={
            'meta': '<meta>....</meta>',
            'otherdata': '<stupidXML>abcdefgh'
        }
class SruUpdateUploaderTest(SeecrTestCase):
    def setUp(self):
        SeecrTestCase.setUp(self)
        self.target = CallTrace('SruUpdateTarget', verbose=True)
        self.uploader = SruUpdateUploader(self.target,
                                          CallTrace('eventlogger'))
        self.sentData = []

        def sendData(anId, data):
            self.sentData.append(data)

        self.uploader._sendData = sendData

        self.upload = CallTrace('Upload')
        self.upload.id = 'some:id'
        self.upload.parts = {
            'meta': '<meta>....</meta>',
            'otherdata': '<stupidXML>ßabcdefgh'
        }

    def testOne(self):
        self.uploader.send(self.upload)
        self.assertEqual(1, len(self.sentData))

        updateRequest = _parse(self.sentData[0])
        self.assertEqual(
            'some:id', xpathFirst(updateRequest,
                                  'ucp:recordIdentifier/text()'))
        self.assertEqual('info:srw/action/1/replace',
                         xpathFirst(updateRequest, 'ucp:action/text()'))
        documentParts = xpath(
            updateRequest,
            'srw:record/srw:recordData/document:document/document:part')
        self.assertEqual(2, len(documentParts))
        self.assertEqual('meta', documentParts[0].attrib['name'])
        self.assertEqual('<meta>....</meta>', documentParts[0].text)
        self.assertEqual('otherdata', documentParts[1].attrib['name'])
        self.assertEqual('<stupidXML>ßabcdefgh', documentParts[1].text)

        self.uploader.delete(self.upload)
        updateRequest = _parse(self.sentData[1])
        self.assertEqual(
            'some:id', xpathFirst(updateRequest,
                                  'ucp:recordIdentifier/text()'))
        self.assertEqual('info:srw/action/1/delete',
                         xpathFirst(updateRequest, 'ucp:action/text()'))

    def testException(self):
        possibleSRUError = b"""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/1</diag:uri>
            <diag:details>Traceback (most recent call last): File "../meresco/components/sru/srurecordupdate.py", line 47, in handleRequest File "../meresco/framework/transaction.py", line 63, in unknown File "../meresco/framework/observable.py", line 101, in __call__ File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 109, in _callonce File "../meresco/framework/observable.py", line 106, in _callonce KeyError: '__id__' </diag:details>
            <diag:message>Invalid component: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        uploader._sendDataToRemote = lambda data: (HTTP_OK, possibleSRUError)
        try:
            uploader.send(self.upload)
            self.fail()
        except InvalidComponentException as e:
            self.assertEqual(self.upload.id, e.uploadId)

    def testInvalidDataException(self):
        possibleSRUValidationError = b"""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/12</diag:uri>
            <diag:details>Xsd Validation error</diag:details>
            <diag:message>Invalid data structure: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>"""
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        uploader._sendDataToRemote = lambda data: (HTTP_OK,
                                                   possibleSRUValidationError)
        try:
            uploader.send(self.upload)
            self.fail("Diagnostic code 12 should raise a validation exception")
        except InvalidDataException as e:
            self.assertEqual(self.upload.id, e.uploadId)

    def testRetryOnServiceUnavailable(self):
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)

        answers = [(HTTP_OK, SUCCES_RESPONSE)]
        datas = []

        def sendDataToRemote(data):
            answer = answers.pop(0)
            datas.append(data)
            return answer

        uploader._sendDataToRemote = sendDataToRemote
        uploader._sendData(1, b"HOW IS EVERYTHING")

        self.assertEqual(0, len(answers))
        self.assertEqual(1, len(datas))

        answers = [(SERVICE_UNAVAILABLE, ''), (HTTP_OK, SUCCES_RESPONSE)]
        datas = []
        uploader._sendData(1, b"HOW IS EVERYTHING")

        self.assertEqual(0, len(answers))
        self.assertEqual(2, len(datas))
        self.assertEqual(1, len(eventLogger.calledMethods))
        self.assertEqual(
            "Status 503, SERVICE_UNAVAILABLE received while trying to upload",
            eventLogger.calledMethods[0].args[0])

    def testRetryOnServiceUnavailableFailsAfter3Times(self):
        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)

        answers = [(SERVICE_UNAVAILABLE, ''), (SERVICE_UNAVAILABLE, ''),
                   (SERVICE_UNAVAILABLE, ''), (HTTP_OK, SUCCES_RESPONSE)]
        datas = []

        def sendDataToRemote(data):
            answer = answers.pop(0)
            datas.append(data)
            return answer

        uploader._sendDataToRemote = sendDataToRemote
        exception = None
        try:
            uploader._sendData(1, "HOW IS EVERYTHING")
            self.fail()
        except Exception as e:
            exception = e

        self.assertFalse(exception == None)
        self.assertEqual('uploadId: "1", message: "HTTP 503: "',
                         str(exception))
        self.assertEqual(1, len(answers))
        self.assertEqual(3, len(datas))
        self.assertEqual(3, len(eventLogger.calledMethods))

    def testParseMessageWithDiagnostic(self):
        SRU_MESSAGE = _parse("""<?xml version="1.0" encoding="UTF-8"?>
<srw:updateResponse xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:ucp="info:lc/xmlns/update-v1">
    <srw:version>1.0</srw:version>
    <ucp:operationStatus>fail</ucp:operationStatus>
    <srw:diagnostics>
        <diag:diagnostic xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/">
            <diag:uri>info:srw/diagnostic/12/12</diag:uri>
            <diag:details>Xsd Validation error</diag:details>
            <diag:message>Invalid component: record rejected</diag:message>
        </diag:diagnostic>
    </srw:diagnostics>
</srw:updateResponse>""")

        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        version, operationStatus, diagnostics = uploader._parseMessage(
            SRU_MESSAGE)
        self.assertEqual("1.0", version)
        self.assertEqual("fail", operationStatus)
        self.assertEqual(("info:srw/diagnostic/12/12", "Xsd Validation error",
                          "Invalid component: record rejected"), diagnostics)

    def testParseMessage(self):
        SRU_MESSAGE = _parse(SUCCES_RESPONSE)

        eventLogger = CallTrace('eventlogger')
        uploader = SruUpdateUploader(self.target, eventLogger)
        version, operationStatus, diagnostics = uploader._parseMessage(
            SRU_MESSAGE)
        self.assertEqual("1.0", version)
        self.assertEqual("success", operationStatus)
        self.assertEqual(None, diagnostics)