Пример #1
0
def user(request, organization, database):
    """Fixture creating a user with no role."""
    user = User.find_or_create(username='******',
                               password='******',
                               nachname='Mittag',
                               position='Vorsitzender',
                               ort='Leuna',
                               organization_id=1)
    database.session.flush()
    return user
Пример #2
0
def verwalter(request, organization, database):
    """Fixture creating a user with role Administrator."""
    user = User.find_or_create(username='******',
                               password='******',
                               vorname='Admin',
                               nachname='istrator',
                               unrestricted_access=True,
                               organization_id=1)
    database.session.flush()
    transaction.commit()
    return user
Пример #3
0
def test_fa_icon_if_system_user(browser):
    from sw.allotmentclub import Log, User
    user = User.find_or_create(username='******')
    Log.create(user=user, name='user data', level='INFO',
               created=datetime.datetime.now(), msg='Test-Log-Eintrag')
    transaction.commit()

    browser.login()
    browser.open('http://localhost/')
    timeline = browser.json['data']['timeline'][0]
    assert timeline['fa_icon'] == 'fa-gear'
    assert 'gravatar_url' not in timeline
Пример #4
0
def test__mail__postmark_inbound_webhook_1(browser):
    """It creates an inbound email for every request."""
    from sw.allotmentclub import Message, User
    user = User.find_or_create(username='******')
    browser.post(
        'http://localhost/mail/postmark_inbound_webhook',
        data={"FromName": "Postmarkapp Support",
              "From": "*****@*****.**",
              "FromFull": {
                  "Email": "*****@*****.**",
                  "Name": "Postmarkapp Support",
                  "MailboxHash": ""
              },
              "To": ("\"Firstname Lastname\" "
                     "<*****@*****.**>"),
              "ToFull": [
                  {
                      "Email": "*****@*****.**",
                      "Name": "Firstname Lastname",
                      "MailboxHash": "SampleHash"
                  }
              ],
              "Cc": ("\"First Cc\" "
                     "<*****@*****.**>, [email protected]>"),
              "CcFull": [
                  {
                      "Email": "*****@*****.**",
                      "Name": "First Cc",
                      "MailboxHash": ""
                  },
                  {
                      "Email": "*****@*****.**",
                      "Name": "",
                      "MailboxHash": ""
                  }
              ],
              "OriginalRecipient": "*****@*****.**",
              "Subject": "Test subject",
              "MessageID": "73e6d360-66eb-11e1-8e72-a8904824019b",
              "ReplyTo": "*****@*****.**",
              "MailboxHash": "SampleHash",
              # "Date": "Fri, 1 Aug 2014 16:45:32 -04:00",
              "Date": "Sat, 19 Aug 2017 19:37:23 +0200 (Mitteleurop?ische",
              "TextBody": "This is a test text body.",
              "HtmlBody": ("<html><body><p>"
                           "This is a test html body."
                           "</p></body></html>"),
              "StrippedTextReply": "This is the reply text",
              "Tag": "TestTag",
              "Headers": [
                  {
                      "Name": "X-Header-Test",
                      "Value": ""
                  },
                  {
                      "Name": "X-Spam-Status",
                      "Value": "No"
                  },
                  {
                      "Name": "X-Spam-Score",
                      "Value": "-0.1"
                  },
                  {
                      "Name": "X-Spam-Tests",
                      "Value": "DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_PASS"
                  }
              ],
              "Attachments": [
                  {
                      "Name": "test.pdf",
                      "Content": MINIMAL_TEST_PDF_CONTENTS,
                      "ContentType": "application/pdf",
                      "ContentLength": 739
                  }
              ]})
    mail = Message.query().one()
    assert '*****@*****.**' == mail.externals[0].email
    assert 'Postmarkapp Support' == mail.externals[0].lastname
    assert [] == mail.members
    assert "Test subject" == mail.subject
    assert user == mail.user
    assert mail.inbound is True
    assert ("<html><body><p>"
            "This is a test html body."
            "</p></body></html>" == mail.body)
    assert 1 == len(mail.attachments)
    assert MINIMAL_TEST_PDF_CONTENTS.encode() == base64.b64encode(
        mail.attachments[0].data)
    assert 'application/pdf' == mail.attachments[0].mimetype
    assert 'test.pdf' == mail.attachments[0].filename
    assert int(mail.attachments[0].size) == len(mail.attachments[0].data)