Skip to content

Commit 3bf2ef5

Browse files
committed
WIP
1 parent 68e699d commit 3bf2ef5

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

.github/workflows/zeyple.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ jobs:
2929
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local only'"
3030
sudo debconf-set-selections <<< "postfix postfix/mailname string localhost"
3131
sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python3-gpg
32+
dpkg -L python3-gpg
3233
sudo gem install --no-document fpm
33-
python -m pip install --upgrade pip setuptools wheel
34-
python -m pip install --upgrade tox
34+
python -m pip install --upgrade pip setuptools==70.0.0
35+
python -m pip install --upgrade mock pycodestyle pytest pytest-cov
3536
- name: Build deb package
3637
run: ./fpm/create
3738
- name: End to end test using deb package
3839
run: sudo bash -ex ./tests/e2e.sh
39-
- name: Test with tox
40-
run: tox
40+
- name: Lint with pycodestyle
41+
run: pycodestyle --show-pep8 --max-line-length=100
42+
- name: Test with pytest
43+
run: env PYTHONPATH=/usr/lib/python3/dist-packages:$PYTHONPATH python -m pytest --cov=zeyple/ --cov-report=html tests/
44+
#run: python -m pytest --cov=zeyple/ --cov-report=html tests/
4145
- name: Upload deb package
4246
uses: actions/upload-artifact@v1
4347
with:

tests/__init__.py

Whitespace-only changes.

tests/test_zeyple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import tempfile
1313
import unittest
1414

15-
from zeyple import zeyple as z
15+
from zeyple import zeyple
1616

1717
KEYS_FNAME = os.path.join(os.path.dirname(__file__), 'keys.gpg')
1818
TEST1_ID = 'D6513C04E24C1F83'
@@ -54,7 +54,7 @@ def setUp(self):
5454
stderr=open('/dev/null'),
5555
)
5656

57-
self.zeyple = z.Zeyple(self.conffile)
57+
self.zeyple = zeyple.Zeyple(self.conffile)
5858
self.zeyple._send_message = Mock() # don't try to send emails
5959

6060
def tearDown(self):

zeyple/zeyple.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# -*- coding: utf-8 -*-
33

44
from configparser import ConfigParser
5-
from io import BytesIO
65
import copy
76
import email
87
import email.encoders
@@ -16,14 +15,6 @@
1615
import sys
1716

1817

19-
def message_from_binary(message):
20-
return email.message_from_bytes(message)
21-
22-
23-
def as_binary_string(email):
24-
return email.as_bytes()
25-
26-
2718
def encode_string(string):
2819
if isinstance(string, bytes):
2920
return string
@@ -84,7 +75,7 @@ def process_message(self, message_data, recipients):
8475
"""Encrypts the message with recipient keys"""
8576
message_data = encode_string(message_data)
8677

87-
in_message = message_from_binary(message_data)
78+
in_message = email.message_from_bytes(message_data)
8879
logging.info(
8980
"Processing outgoing message %s", in_message['Message-id'])
9081

@@ -190,7 +181,7 @@ def _encrypt_message(self, in_message, key_id):
190181
# remove superfluous header
191182
del mixed['MIME-Version']
192183

193-
payload = as_binary_string(mixed)
184+
payload = mixed.as_bytes()
194185

195186
encrypted_payload = self._encrypt_payload(payload, [key_id])
196187

0 commit comments

Comments
 (0)