From c9f15975713746764f7115c23de52690ff34f526 Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Wed, 14 Jun 2023 15:25:42 -0400 Subject: [PATCH] add docker tests and fix sorting --- Makefile | 6 ++++++ mail4one/poputils.py | 3 +-- mail4one/smtp.py | 2 +- runtests.sh | 8 ++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100755 runtests.sh diff --git a/Makefile b/Makefile index 65e920e..525f4f8 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,12 @@ shell: test: pipenv run python -m unittest discover +docker-tests: + docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.11-alpine sh runtests.sh + docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.10-alpine sh runtests.sh + docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.11 sh runtests.sh + docker run --pull=always -v `pwd`:/app -w /app --rm -it python:3.10 sh runtests.sh + requirements.txt: Pipfile.lock pipenv requirements > requirements.txt diff --git a/mail4one/poputils.py b/mail4one/poputils.py index 4afc60c..e2392b9 100644 --- a/mail4one/poputils.py +++ b/mail4one/poputils.py @@ -118,8 +118,7 @@ def get_mails_list(dirpath: Path) -> list[MailEntry]: def set_nid(entries: list[MailEntry]): - entries.sort(reverse=True, key=lambda e: e.c_time) - entries = sorted(entries, reverse=True, key=lambda e: e.c_time) + entries.sort(reverse=True, key=lambda e: (e.c_time, e.uid)) for i, entry in enumerate(entries, start=1): entry.nid = i diff --git a/mail4one/smtp.py b/mail4one/smtp.py index d28730b..f4684fb 100644 --- a/mail4one/smtp.py +++ b/mail4one/smtp.py @@ -50,7 +50,7 @@ class MyHandler(AsyncMessage): gen = BytesGenerator(fp, policy=email.policy.SMTP) gen.flatten(m) for mbox in all_mboxes: - shutil.copy2(temp_email_path, self.mails_path / mbox / 'new') + shutil.copy(temp_email_path, self.mails_path / mbox / 'new') def protocol_factory_starttls(mails_path: Path, diff --git a/runtests.sh b/runtests.sh new file mode 100755 index 0000000..a7c0456 --- /dev/null +++ b/runtests.sh @@ -0,0 +1,8 @@ +#!/usr/bin/sh + + +python3 -m venv /tmp/m41.venv +. /tmp/m41.venv/bin/activate +python3 -m pip install -q -r requirements.txt +python3 -m unittest discover +