Пример #1
0
def test_main_quick(default_mailer_fxt, config_fxt, monkeypatch):
    monkeypatch.setattr('gnomegmail.sys.argv', ['prog', '-q'])

    with pytest.raises(MyTestException):
        gnomegmail.main()

    assert gnomegmail.sys.exit.calledwith(0)
Пример #2
0
def test_main_quick(default_mailer_fxt, config_fxt, monkeypatch):
    monkeypatch.setattr('gnomegmail.sys.argv', ['prog', '-q'])

    with pytest.raises(MyTestException):
        gnomegmail.main()

    assert gnomegmail.sys.exit.calledwith(0)
Пример #3
0
def test_main(default_mailer_fxt, config_fxt, keyring_fxt,
              notify_fxt, web_fxt, oauth_fxt,
              monkeypatch, su, bcc, cc, attach, body):

    rfc822txt = None

    args = ['body', 'cc', 'bcc', 'su', 'attach']
    argvals = locals()
    queries = ['='.join((x, argvals[x])) for x in args if argvals[x]]

    mailto = "mailto:[email protected]"
    if queries:
        mailto += "?" + '&'.join(queries)

    monkeypatch.setattr('gnomegmail.sys.argv', ['prog', mailto])

    myform = spy_decorator(gnomegmail.GMailAPI.form_message)
    with patch.object(gnomegmail.GMailAPI, 'form_message', myform):
        gnomegmail.main()
        rfc822txt = gnomegmail.GMailAPI.form_message.msgtxt[0]

    assert gnomegmail.GMailAPI.upload_mail.called

    assert "To: [email protected]" in rfc822txt

    if body:
        assert b64grep(body, rfc822txt)

    if su:
        assert "Subject: " + su in rfc822txt
    elif attach:
        assert "Subject: Sending " in rfc822txt
    else:
        assert "Subject:" not in rfc822txt

    if attach:
        assert "Content-Disposition: attachment; " in rfc822txt
    else:
        assert "Content-Disposition: attachment; " not in rfc822txt

    if cc:
        assert b64grep(cc, rfc822txt)
    else:
        assert "Cc: " not in rfc822txt

    if bcc:
        assert b64grep(bcc, rfc822txt)
    else:
        assert "Bcc: " not in rfc822txt
Пример #4
0
def test_main(default_mailer_fxt, config_fxt, keyring_fxt,
              notify_fxt, web_fxt, oauth_fxt,
              monkeypatch, su, bcc, cc, attach, body):

    args = ['body', 'cc', 'bcc', 'su', 'attach']
    argvals = locals()
    queries = ['='.join((x, argvals[x])) for x in args if argvals[x]]

    mailto = "mailto:[email protected]"
    if queries:
        mailto += "?" + '&'.join(queries)

    monkeypatch.setattr('gnomegmail.sys.argv', ['prog', mailto])

    gnomegmail.main()
Пример #5
0
def test_main(default_mailer_fxt, config_fxt, keyring_fxt, notify_fxt, web_fxt,
              oauth_fxt, monkeypatch, su, bcc, cc, attach, body):

    rfc822txt = None

    args = ['body', 'cc', 'bcc', 'su', 'attach']
    argvals = locals()
    queries = ['='.join((x, argvals[x])) for x in args if argvals[x]]

    mailto = "mailto:[email protected]"
    if queries:
        mailto += "?" + '&'.join(queries)

    monkeypatch.setattr('gnomegmail.sys.argv', ['prog', mailto])

    myform = spy_decorator(gnomegmail.GMailAPI.form_message)
    with patch.object(gnomegmail.GMailAPI, 'form_message', myform):
        gnomegmail.main()
        rfc822txt = gnomegmail.GMailAPI.form_message.msgtxt[0]

    assert gnomegmail.GMailAPI.upload_mail.called

    assert "To: [email protected]" in rfc822txt

    if body:
        assert b64grep(body, rfc822txt)

    if su:
        assert "Subject: " + su in rfc822txt
    elif attach:
        assert "Subject: Sending " in rfc822txt
    else:
        assert "Subject:" not in rfc822txt

    if attach:
        assert "Content-Disposition: attachment; " in rfc822txt
    else:
        assert "Content-Disposition: attachment; " not in rfc822txt

    if cc:
        assert b64grep(cc, rfc822txt)
    else:
        assert "Cc: " not in rfc822txt

    if bcc:
        assert b64grep(bcc, rfc822txt)
    else:
        assert "Bcc: " not in rfc822txt