コード例 #1
0
ファイル: __init__.py プロジェクト: BjarniRunar/Mailpile
def _initialize_mailpile_for_testing(workdir, test_data):
    config = mailpile.config.manager.ConfigManager(
        workdir=workdir, rules=mailpile.config.defaults.CONFIG_RULES)
    session = mailpile.ui.Session(config)
    session.config.load(session)
    session.main = True
    ui = session.ui = SilentInteraction(config)

    mailpile.util.TESTING = True
    config.sys.http_port = random.randint(33500, 34000)
    #   config.sys.debug = 'log'

    mp = mailpile.Mailpile(session=session)
    session.config.plugins.load('demos')
    mp.set('prefs.index_encrypted=true')

    # Add some mail, scan it.
    # Create local mailboxes
    session.config.open_local_mailbox(session)
    for t in TAGS:
        AddTag(session, arg=[t]).run(save=False)
        session.config.get_tag(t).update(TAGS[t])

    mp.add(test_data)
    mp.rescan('mailboxes')
    mp.profiles_add(MY_FROM, '=', MY_NAME)

    return mp, session, config, ui
コード例 #2
0
ファイル: __init__.py プロジェクト: pedroguima/Mailpile
def _initialize_mailpile_for_testing(workdir, test_data):
    config = mailpile.app.ConfigManager(workdir=workdir,
                                        rules=mailpile.defaults.CONFIG_RULES)
    config.sys.http_port = random.randint(33500, 34000)
    session = mailpile.ui.Session(config)
    session.config.load(session)
    session.main = True
    ui = session.ui = SilentInteraction(config)

    mp = mailpile.Mailpile(session=session)
    session.config.plugins.load('demos')
    mp.set('prefs.index_encrypted=true')

    # Add some mail, scan it.
    # Create local mailboxes
    session.config.open_local_mailbox(session)
    for t in TAGS:
        AddTag(session, arg=[t]).run(save=False)
        session.config.get_tag(t).update(TAGS[t])
    Filter(session,
           arg=['new', '@incoming', '+Inbox', '+New',
                'Incoming mail filter']).run(save=False)

    mp.add(test_data)
    mp.rescan()

    return mp, session, config, ui
コード例 #3
0
def get_shared_mailpile():
    global MP
    if MP is not None:
        return MP

    cwd = os.getcwd()
    workdir = os.path.join(cwd, "testing", "tmp")
    test_data = os.path.join(cwd, "testing", "Maildir")

    if os.path.exists(workdir):
        shutil.rmtree(workdir)
    if not os.path.exists(os.path.join(test_data, "new")):
        os.mkdir(os.path.join(test_data, "new"))

    sys.stderr.write('Preparing shared Mailpile test environment, '
                     'please wait. 8-)\n')

    MP = mailpile.Mailpile(workdir=workdir, ui=SilentInteraction)
    MP._session.config.plugins.load('demos')

    _initialize_mailpile_for_testing(MP, test_data)
    return MP
コード例 #4
0
def get_shared_mailpile():
    global MP
    if MP is not None:
        return MP

    cwd = os.getcwd()
    workdir = os.path.join(cwd, "testing", "tmp")
    test_data = os.path.join(cwd, "testing", "Maildir")

    if os.path.exists(workdir):
        shutil.rmtree(workdir)
    if not os.path.exists(os.path.join(test_data, "new")):
        os.mkdir(os.path.join(test_data, "new"))

    sys.stderr.write('Preparing shared Mailpile test environment, '
                     'please wait. 8-)\n')

    MP = mailpile.Mailpile(workdir=workdir, ui=SilentInteraction)

    # Add some mail, scan it.
    MP.add(test_data)
    MP.rescan()
    return MP
コード例 #5
0
 def setUp(self):
     self.mp = mailpile.Mailpile()
コード例 #6
0
 def test_key_import(self):
     m = mailpile.Mailpile()
     res = action(m._session, "crypto/gpg/importkey", 'testing/pub.key')
     self.assertEqual(res.result["results"]["count"], 1)