示例#1
0
    def test_Chaff(self):
        """Unit test for class Chaff"""
        tmp_dir = mkdtemp(prefix='bleachbit-chaff')
        # con=Clinton content
        con_path = os.path.join(tmp_dir, 'content.json.bz2')
        # sub=Clinton subject
        sub_path = os.path.join(tmp_dir, 'subject.json.bz2')
        ts_path = os.path.join(tmp_dir, 'ts.json.bz2')  # ts = 2600 Magazine

        for i in ('download', 'already downloaded'):
            ret = download_models(content_model_path=con_path,
                                  subject_model_path=sub_path,
                                  twentysixhundred_model_path=ts_path)
            self.assertIsInstance(ret, bool)
            self.assertTrue(ret)

        self.assertExists(con_path)
        self.assertExists(sub_path)
        self.assertExists(ts_path)

        generated_file_names = generate_emails(5, tmp_dir, con_path, sub_path)

        self.assertEqual(len(generated_file_names), 5)

        for fn in generated_file_names:
            self.assertExists(fn)
            self.assertGreater(getsize(fn), 100)

        generated_file_names = generate_2600(5, tmp_dir, ts_path)

        rmtree(tmp_dir)
示例#2
0
def make_files_thread(email_count, content_model_path, subject_model_path, email_output_folder, delete_when_finished, on_progress):
    generated_file_names = generate_emails(email_count, content_model_path,
                                           subject_model_path, email_output_folder, on_progress=on_progress)
    if delete_when_finished:
        on_progress(0, msg=_('Deleting files'))
        for i in range(0, email_count):
            os.unlink(generated_file_names[i])
            on_progress(1.0 * (i+1)/email_count)
    on_progress(1.0, is_done=True)
示例#3
0
def make_files_thread(file_count, inspiration, output_folder, delete_when_finished, on_progress):
    if inspiration == 0:
        generated_file_names = generate_2600(
            file_count, output_folder, on_progress=on_progress)
    elif inspiration == 1:
        generated_file_names = generate_emails(
            file_count, output_folder, on_progress=on_progress)
    if delete_when_finished:
        on_progress(0, msg=_('Deleting files'))
        for i in range(0, file_count):
            os.unlink(generated_file_names[i])
            on_progress(1.0 * (i+1)/file_count)
    on_progress(1.0, is_done=True)
示例#4
0
    def test_Chaff(self):
        """Unit test for class Chaff"""
        tmp_dir = mkdtemp(prefix='bleachbit-chaff')
        con_path = os.path.join(tmp_dir, 'content.json.bz2')
        sub_path = os.path.join(tmp_dir, 'subject.json.bz2')

        for i in ('download', 'already downloaded'):
            ret = download_models(content_model_path=con_path,
                                  subject_model_path=sub_path)
            self.assertIsInstance(ret, bool)
            self.assertTrue(ret)

        generated_file_names = generate_emails(5, con_path, sub_path, tmp_dir)

        self.assertEqual(len(generated_file_names), 5)

        for fn in generated_file_names:
            self.assertExists(fn)
            self.assertGreater(getsize(fn), 100)

        rmtree(tmp_dir)
示例#5
0
    def test_Chaff(self):
        """Unit test for class Chaff"""
        tmp_dir = mkdtemp(prefix='bleachbit-chaff')
        models_dir = os.path.join(tmp_dir, 'model')
        os.mkdir(models_dir)
        # con=Clinton content
        con_path = os.path.join(models_dir, 'clinton_content_model.json.bz2')
        # sub=Clinton subject
        sub_path = os.path.join(models_dir, 'clinton_subject_model.json.bz2')
        # ts = 2600 Magazine
        ts_path = os.path.join(models_dir, '2600_model.json.bz2')

        for _i in ('download', 'already downloaded'):
            ret = download_models(models_dir=models_dir)
            self.assertIsInstance(ret, bool)
            self.assertTrue(ret)

        self.assertExists(con_path)
        self.assertExists(sub_path)
        self.assertExists(ts_path)

        generated_file_names = generate_emails(5, tmp_dir, models_dir)

        self.assertEqual(len(generated_file_names), 5)

        for fn in generated_file_names:
            self.assertExists(fn)
            self.assertGreater(getsize(fn), 100)
            with open(fn) as f:
                contents = f.read()
                self.assertIn('To: ', contents)
                self.assertIn('From: ', contents)
                self.assertIn('Sent: ', contents)
                self.assertIn('Subject: ', contents)
                self.assertNotIn('base64', contents)

        generated_file_names = generate_2600(5, tmp_dir, models_dir)

        rmtree(tmp_dir)