Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: test WebHook
run: python test_webhook.py
- name: test Digest
run: python test_digest.py
run: python test_digest.py
8 changes: 5 additions & 3 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
from email.utils import formataddr
from email.utils import formataddr, make_msgid
from email.generator import Generator
import email.charset
from io import StringIO
Expand Down Expand Up @@ -755,8 +755,10 @@ def sendMail(
msg["From"] = formataddr((from_name, from_addr))
msg["To"] = ",".join(to_addr)
msg["Subject"] = Header(subject)
if msgid:
msg["Message-ID"] = msgid
if not msgid:
msgid = make_msgid()
msg["Message-ID"] = msgid

if inreplyto:
msg["In-Reply-To"] = inreplyto

Expand Down
1 change: 1 addition & 0 deletions test_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

config = {
"SMTP_HOST": "localhost",
"SMTP_PORT": "8080",
"EMAIL_FROM": "test@localhost",
"TEMPLATES_DIR": "tests/templates",
"DIGEST_SENDER":"W3C Webmaster via GitHub API",
Expand Down
1 change: 1 addition & 0 deletions test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

config = {
"SMTP_HOST": "localhost",
"SMTP_PORT": "8080",
"EMAIL_FROM": "test@localhost",
"TEMPLATES_DIR": "tests/templates",
"GH_OAUTH_TOKEN": "foo",
Expand Down
4 changes: 3 additions & 1 deletion test_webhook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from mock import patch, call
import email
import email.utils
import unittest
import smtplib
import json
Expand Down Expand Up @@ -42,8 +43,9 @@ def test_ip_check_403(self):
)
assert rv.status_code == 403

@patch("index.make_msgid", return_value="<[email protected]>")
@patch("smtplib.SMTP", autospec=True)
def test_w3c_tr_published(self, mock_smtp):
def test_w3c_tr_published(self, mock_smtp, mock_make_msgid):
data = self.read_file("tests/trpublished-notif.json")
rv = requests.post(
"http://localhost:8000/",
Expand Down
1 change: 1 addition & 0 deletions tests/trpublished-notif.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ Content-Type: text/plain; charset="utf-8"; format="flowed"
From: W3C Webmaster via W3C API <test@localhost>
To: dom@localhost
Subject: "SHACL Use Cases and Requirements" published as a Working Draft
Message-ID: <[email protected]>

"SHACL Use Cases and Requirements" has just been published as a W3C Working Draft dated 2016-01-22 at http://www.w3.org/TR/2016/WD-shacl-ucr-20160122/.