Beispiel #1
0
 def __iter__(self):
     try:
         # Reset the session.
         LaunchpadLayer.resetSessionDb()
         # Yield control to asyncore for a second, just to be a
         # little bit nice.  We could be even nicer by moving this
         # whole teardown/setup dance to a thread and waiting for
         # it to be done, but there's not a (known) compelling need
         # for that right now, and doing it this way is slightly
         # simpler.
         yield ''
         DatabaseLayer.testSetUp()
         yield ''
         # Reset the librarian.
         LibrarianLayer.testTearDown()
         yield ''
         # Reset the database.
         DatabaseLayer.testTearDown()
         yield ''
         LibrarianLayer.testSetUp()
     except (SystemExit, KeyboardInterrupt):
         raise
     except:
         print "Hm, serious error when trying to clean up the test."
         traceback.print_exc()
     # We're done, so we can yield the body.
     yield '\n'
Beispiel #2
0
 def test_librarian_is_reset(self):
     # Add a file. We use remoteAddFile because it does not need the CA
     # loaded to work.
     client = LibrarianClient()
     LibrarianTestCase.url = client.remoteAddFile(
         self.sample_data, len(self.sample_data),
         StringIO(self.sample_data), 'text/plain')
     self.failUnlessEqual(
         urlopen(LibrarianTestCase.url).read(), self.sample_data)
     # Perform the librarian specific between-test code:
     LibrarianLayer.testTearDown()
     LibrarianLayer.testSetUp()
     # Which should have nuked the old file.
     # XXX: StuartBishop 2006-06-30 Bug=51370:
     # We should get a DownloadFailed exception here.
     data = urlopen(LibrarianTestCase.url).read()
     self.failIfEqual(data, self.sample_data)
 def test_librarian_is_reset(self):
     # Add a file. We use remoteAddFile because it does not need the CA
     # loaded to work.
     client = LibrarianClient()
     LibrarianTestCase.url = client.remoteAddFile(
             self.sample_data, len(self.sample_data),
             StringIO(self.sample_data), 'text/plain'
             )
     self.failUnlessEqual(
             urlopen(LibrarianTestCase.url).read(), self.sample_data
             )
     # Perform the librarian specific between-test code:
     LibrarianLayer.testTearDown()
     LibrarianLayer.testSetUp()
     # Which should have nuked the old file.
     # XXX: StuartBishop 2006-06-30 Bug=51370:
     # We should get a DownloadFailed exception here.
     data = urlopen(LibrarianTestCase.url).read()
     self.failIfEqual(data, self.sample_data)