add docker tests and fix sorting

This commit is contained in:
Balakrishnan Balasubramanian 2023-06-14 15:25:42 -04:00
parent dd18bcdfbe
commit c9f1597571
4 changed files with 16 additions and 3 deletions

View File

@ -6,6 +6,12 @@ shell:
test: test:
pipenv run python -m unittest discover 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 requirements.txt: Pipfile.lock
pipenv requirements > requirements.txt pipenv requirements > requirements.txt

View File

@ -118,8 +118,7 @@ def get_mails_list(dirpath: Path) -> list[MailEntry]:
def set_nid(entries: list[MailEntry]): def set_nid(entries: list[MailEntry]):
entries.sort(reverse=True, key=lambda e: e.c_time) entries.sort(reverse=True, key=lambda e: (e.c_time, e.uid))
entries = sorted(entries, reverse=True, key=lambda e: e.c_time)
for i, entry in enumerate(entries, start=1): for i, entry in enumerate(entries, start=1):
entry.nid = i entry.nid = i

View File

@ -50,7 +50,7 @@ class MyHandler(AsyncMessage):
gen = BytesGenerator(fp, policy=email.policy.SMTP) gen = BytesGenerator(fp, policy=email.policy.SMTP)
gen.flatten(m) gen.flatten(m)
for mbox in all_mboxes: 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, def protocol_factory_starttls(mails_path: Path,

8
runtests.sh Executable file
View File

@ -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