def _generate_mails(limit, mail_paths, seed, server_name, username):
    mails = []
    for path in mail_paths:
        mbox_mails = mbox(path, factory=None)
        mails.extend(mbox_mails)
    gen = MailGenerator(username, server_name, mails, random=random.Random(seed))
    markov_mails = [gen.generate_mail() for _ in range(limit)]
    return markov_mails
Exemplo n.º 2
0
def _generate_mails(limit, mail_paths, seed, server_name, username):
    mails = []
    for path in mail_paths:
        mbox_mails = mbox(path, factory=None)
        mails.extend(mbox_mails)
    gen = MailGenerator(username, server_name, mails, random=random.Random(seed))
    markov_mails = [gen.generate_mail() for _ in range(limit)]
    return markov_mails
Exemplo n.º 3
0
    def test_generator(self):
        mail = """Content-Type: text/plain; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nSubject: Scott\'s Laws with a longer subject Scott\'s Laws\nTo: [email protected]\nFrom: [email protected]\nDate: Sun, 18 Oct 2015 21:45:13 -0000\nX-Tags: \nX-Leap-Encryption: true\nX-Leap-Signature: valid\n\nFirst Law: No matter what goes wrong, it will probably look right. Scott\'s Second Law: When an error has been detected and corrected, it will probably look right. Scott\'s Second Law: When an error has been found in error, it will probably look right. Scott\'s Second Law: When an error has been found in error, it will probably look right. Scott\'s Second Law: When an error has been found in error, it will be impossible to fit the original quantity back into the \n\n First Law: No matter what goes wrong, it will be impossible to fit the original quantity back into the \n\n Scott\'s Second Law: When an error has been found in error, it will be found to have been wrong in the first place. After the correction has been found in error, it will be impossible to fit the original quantity back into the \n\n Second Law: When an error"""
        receiver = 'alice'
        domain_name = 'domain.test'
        mbox_file = pkg_resources.resource_filename('test.unit.fixtures', 'mbox')
        mails = mbox(mbox_file)
        rnd = random.Random(0)

        with patch('pixelated.support.mail_generator.time.time') as time_mock:
            time_mock.return_value = 1446029232.636018

            gen = MailGenerator(receiver, domain_name, mails, rnd)

            result = gen.generate_mail()

            self.assertEqual(mail, result.as_string())