コード例 #1
0
 def test_clientWrongDatabase(self):
     # If the client is using the wrong database, the server should refuse
     # the upload, causing LibrarianClient to raise UploadFailed.
     client = LibrarianClient()
     # Force the client to mis-report its database
     client._getDatabaseName = lambda cur: "wrong_database"
     try:
         client.addFile("sample.txt", 6, StringIO("sample"), "text/plain")
     except UploadFailed as e:
         msg = e.args[0]
         self.failUnless(msg.startswith("Server said: 400 Wrong database"), "Unexpected UploadFailed error: " + msg)
     else:
         self.fail("UploadFailed not raised")
コード例 #2
0
 def test_clientWrongDatabase(self):
     # If the client is using the wrong database, the server should refuse
     # the upload, causing LibrarianClient to raise UploadFailed.
     client = LibrarianClient()
     # Force the client to mis-report its database
     client._getDatabaseName = lambda cur: 'wrong_database'
     try:
         client.addFile('sample.txt', 6, StringIO('sample'), 'text/plain')
     except UploadFailed as e:
         msg = e.args[0]
         self.assertTrue(msg.startswith('Server said: 400 Wrong database'),
                         'Unexpected UploadFailed error: ' + msg)
     else:
         self.fail("UploadFailed not raised")