Skip to content

Commit c94223f

Browse files
committed
Add github actions and fix tests
1 parent 2ae7247 commit c94223f

3 files changed

Lines changed: 43 additions & 4 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Python package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install flake8 pytest
23+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
24+
- name: Lint with flake8
25+
run: |
26+
# stop the build if there are Python syntax errors or undefined names
27+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
28+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
29+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
30+
- name: Test with pytest
31+
run: |
32+
pytest

sifter/notificationmethods/mailto.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from urllib.parse import urlparse
1+
from urllib import parse as urlparse
22
import sifter.notificationmethod
33

44
__all__ = ('MailtoNotificationMethod',)
@@ -19,7 +19,7 @@ def parse_mailto_url(url):
1919
@classmethod
2020
def test_valid(cls, notification_uri):
2121
uri_headers = cls.parse_mailto_url(notification_uri)
22-
uri_headers = dict((k.lower(), v) for k,v in uri_headers.iteritems())
22+
uri_headers = dict((k.lower(), v) for k,v in uri_headers.items())
2323
if any(h in uri_headers for h in ('auto-submitted', 'received', 'date', 'message-id', 'from')):
2424
return (False, "Notification method mailto - illegal header")
2525
return (True, '')
@@ -35,4 +35,3 @@ def test_capability(cls, notification_uri, notification_capability):
3535

3636

3737
MailtoNotificationMethod.register()
38-

sifter/t/test_evaluation.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,17 @@ def setUp(self):
3535
rule_fh.close()
3636

3737
def test_msg_rule_cross_product(self):
38+
def to_list(obj):
39+
if obj is None or isinstance(obj, (str, int)):
40+
return obj
41+
elif isinstance(obj, (tuple)):
42+
return tuple(to_list(item) for item in obj)
43+
else:
44+
return list(obj)
45+
3846
for result in self.EVAL_RESULTS:
3947
self.assertEqual(
40-
self.rules[result[1]].evaluate(self.messages[result[0]]),
48+
[(action, to_list(value)) for action, value in self.rules[result[1]].evaluate(self.messages[result[0]])],
4149
result[2]
4250
)
4351

0 commit comments

Comments
 (0)