Ejemplo n.º 1
0
    def test_encrypted(self):
        mock_pipe = test_helper.get_mock_pipeline(
            [helper.PROCESS_FILE, helper.TEXT])

        detector = unpack_archive.Subscriber(mock_pipe)
        detector.setup({
            helper.DATA_ROOT: 'local_data',
            helper.TAG: 'test',
            helper.WORKER_ID: 0
        })

        doc = document.get_document(
            test_helper.get_test_path('password-protected.zip'))

        doc.docid = '4321'

        with open(doc.path, 'rb') as inp:
            detector.consume(doc, inp)

        self.assertEqual(1, len(mock_pipe.consumer.produced))
Ejemplo n.º 2
0
    def test_simple(self):
        mock_pipe = test_helper.get_mock_pipeline(
            [helper.PROCESS_FILE, helper.TEXT])

        detector = unpack_archive.Subscriber(mock_pipe)
        detector.setup({
            helper.DATA_ROOT: 'local_data',
            helper.TAG: 'test',
            helper.WORKER_ID: 0
        })

        doc = document.get_document(test_helper.get_test_path('two_files.zip'))

        doc.docid = '4321'

        with open(doc.path, 'rb') as inp:
            detector.consume(doc, inp)

        self.assertEqual(2, len(mock_pipe.consumer.produced))
        self.assertEqual(
            'txt', mock_pipe.consumer.produced[1][0].path.split('/')[-1].split(
                '.')[-1])