Skip to content

Commit 4e3b527

Browse files
committed
WIP
1 parent 68e699d commit 4e3b527

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

.github/workflows/zeyple.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ jobs:
3131
sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python3-gpg
3232
sudo gem install --no-document fpm
3333
python -m pip install --upgrade pip setuptools wheel
34-
python -m pip install --upgrade tox
34+
python -m pip install --upgrade mock pycodestyle pytest pytest-cov
3535
- name: Build deb package
3636
run: ./fpm/create
3737
- name: End to end test using deb package
3838
run: sudo bash -ex ./tests/e2e.sh
39-
- name: Test with tox
40-
run: tox
39+
- name: Lint with pycodestyle
40+
run: pycodestyle --show-pep8 --max-line-length=100
41+
- name: Test with pytest
42+
run: env PYTHONPATH=/usr/lib/python3/dist-packages:$PYTHONPATH python -m pytest --cov=zeyple/ --cov-report=html tests/
43+
#run: python -m pytest --cov=zeyple/ --cov-report=html tests/
4144
- name: Upload deb package
4245
uses: actions/upload-artifact@v1
4346
with:

tests/test_zeyple.py

+2-2
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

+2-11
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)