def test_MultipartParserSeveralReadingSizes(self): # The pure fact that the parser ends is good, # there's really nothing else to check. for size in [2**i for i in xrange(20)]: message = self._createMIMEMessage(True) inputContent= StringIO.StringIO(message) handler = ngamsMIMEMultipart.ContainerBuilderHandler() parser = ngamsMIMEMultipart.MIMEMultipartParser(handler, inputContent, len(message), size) parser.parse()
def _test_MultipartParser(self, onlyDirs): message = self._createMIMEMessage(onlyDirs) inputContent= StringIO.StringIO(message) handler = ngamsMIMEMultipart.ContainerBuilderHandler() parser = ngamsMIMEMultipart.MIMEMultipartParser(handler, inputContent, len(message), 1024000) parser.parse() root = handler.getRoot() self.assertTrue(root, "No container found") self.assertEquals("toplevel", root.getContainerName()) nContainers = self._countContainers(root) self.assertEquals(nContainers, len(self.mydirs), "Not all containers found in the MIME message") if not onlyDirs: nFiles = self._countFiles(root) self.assertEquals(nFiles, len(self.myfiles), "Not all files found in the MIME message")