def test_container_gz(self):
        """Check the type gz of the container of an archive"""

        mbox = MBoxArchive(self.cfiles['gz'])
        container = mbox.container
        self.assertIsInstance(container, gzip.GzipFile)
        container.close()
    def test_container_bz2(self):
        """Check the type bz2 of the container of an archive"""

        mbox = MBoxArchive(self.cfiles['bz2'])
        container = mbox.container
        self.assertIsInstance(container, bz2.BZ2File)
        container.close()
    def test_container(self):
        """Check the type of the container of an archive"""

        import _io
        mbox = MBoxArchive(self.files['single'])
        container = mbox.container
        self.assertIsInstance(container, _io.BufferedReader)
        container.close()
    def test_compressed(self):
        """Test compressed properties"""

        mbox = MBoxArchive(self.cfiles['bz2'])
        self.assertEqual(mbox.compressed_type, 'bz2')
        self.assertEqual(mbox.is_compressed(), True)

        mbox = MBoxArchive(self.cfiles['gz'])
        self.assertEqual(mbox.compressed_type, 'gz')
        self.assertEqual(mbox.is_compressed(), True)

        mbox = MBoxArchive(self.cfiles['zip'])
        self.assertEqual(mbox.compressed_type, 'zip')
        self.assertEqual(mbox.is_compressed(), True)
Esempio n. 5
0
    def test_container(self):
        """Check the type of the container of an archive"""

        mbox = MBoxArchive(self.cfiles['bz2'])
        container = mbox.container
        self.assertIsInstance(container, bz2.BZ2File)
        container.close()

        mbox = MBoxArchive(self.cfiles['gz'])
        container = mbox.container
        self.assertIsInstance(container, gzip.GzipFile)
        container.close()

        import _io
        mbox = MBoxArchive(self.files['single'])
        container = mbox.container
        self.assertIsInstance(container, _io.BufferedReader)
        container.close()
Esempio n. 6
0
    def test_container_zip(self):
        """Check the type zip of the container of an archive"""

        mbox = MBoxArchive(self.cfiles['zip'])
        container = mbox.container
        self.assertIsInstance(container, zipfile.ZipExtFile)
        container.close()

        with zipfile.ZipFile(self.cfiles['zip'], 'w') as f_out:
            f_out.write(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data/mbox/mbox_single.mbox'))
            f_out.write(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data/mbox/mbox_no_fields.mbox'))

        mbox = MBoxArchive(self.cfiles['zip'])
        with self.assertLogs(logger, level='ERROR') as cm:
            container = mbox.container
            container.close()
            self.assertEqual(cm.output[0], 'ERROR:perceval.backends.core.mbox:Zip %s contains more than one file, '
                                           'only the first uncompressed' % mbox.filepath)
Esempio n. 7
0
    def test_filepath(self):
        """Test filepath property"""

        mbox = MBoxArchive(self.cfiles['gz'])
        self.assertEqual(mbox.filepath, self.cfiles['gz'])
Esempio n. 8
0
    def test_not_compressed(self):
        """Check the properties of a non-compressed archive"""

        mbox = MBoxArchive(self.files['single'])
        self.assertEqual(mbox.compressed_type, None)
        self.assertEqual(mbox.is_compressed(), False)