aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2022-04-19 22:26:02 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2022-04-27 21:01:56 +0300
commit5babcc48a0605b8e592bfd73b1664730d00acce7 (patch)
tree1bc3d67e44ee322bc60cc7b8c5b106002ff0846b /tests
parentpkgdev commit: new summary for stabilize ALLARCHES (diff)
downloadpkgdev-5babcc48a0605b8e592bfd73b1664730d00acce7.tar.gz
pkgdev-5babcc48a0605b8e592bfd73b1664730d00acce7.tar.bz2
pkgdev-5babcc48a0605b8e592bfd73b1664730d00acce7.zip
pkgdev mask: offer to send email to gentoo-dev ML
Resolves: https://github.com/pkgcore/pkgdev/issues/36 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/test_pkgdev_mask.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/scripts/test_pkgdev_mask.py b/tests/scripts/test_pkgdev_mask.py
index dcd0327..fa6342b 100644
--- a/tests/scripts/test_pkgdev_mask.py
+++ b/tests/scripts/test_pkgdev_mask.py
@@ -1,4 +1,5 @@
import os
+import sys
import textwrap
from datetime import datetime, timedelta, timezone
from functools import partial
@@ -83,6 +84,18 @@ class TestPkgdevMaskParseArgs:
options, _ = tool.parse_args(['mask', 'cat/pkg'])
assert options.atoms == [atom_cls('cat/pkg')]
+ def test_email_not_rites(self, repo, make_git_repo, capsys, tool):
+ git_repo = make_git_repo(repo.location)
+
+ # masked pkg
+ repo.create_ebuild('cat/pkg-0')
+ git_repo.add_all('cat/pkg-0')
+ with pytest.raises(SystemExit), \
+ chdir(repo.location):
+ tool.parse_args(['mask', '--email', 'cat/pkg'])
+ _, err = capsys.readouterr()
+ assert err.strip() == "pkgdev mask: error: last rites required for email support"
+
class TestPkgdevMask:
@@ -202,6 +215,31 @@ class TestPkgdevMask:
""")
self.masks_path.write_text("") # Reset the contents of package.mask
+ @pytest.mark.skipif(sys.platform == "darwin", reason="no xdg-email on mac os")
+ def test_last_rites_with_email(self, tmp_path):
+ output_file = tmp_path / 'mail.txt'
+ for rflag in ('-r', '--rites'):
+ with os_environ(EDITOR="sed -i '1s/$/mask comment/'", MAILER=f"> {output_file} echo"), \
+ patch('sys.argv', self.args + ['cat/pkg', rflag, '--email']), \
+ pytest.raises(SystemExit), \
+ chdir(pjoin(self.repo.path)):
+ self.script()
+ out = output_file.read_text()
+ assert 'mailto:gentoo-dev-announce@lists.gentoo.org' in out
+
+ self.masks_path.write_text("") # Reset the contents of package.mask
+
+ @pytest.mark.skipif(sys.platform == "darwin", reason="no xdg-email on mac os")
+ def test_last_email_bad_mailer(self, capsys):
+ for rflag in ('-r', '--rites'):
+ with os_environ(EDITOR="sed -i '1s/$/mask comment/'", MAILER="false"), \
+ patch('sys.argv', self.args + ['cat/pkg', rflag, '--email']), \
+ pytest.raises(SystemExit), \
+ chdir(pjoin(self.repo.path)):
+ self.script()
+ _, err = capsys.readouterr()
+ assert err.strip() == "pkgdev mask: error: failed opening email composer"
+
def test_mask_bugs(self):
removal_date = self.today + timedelta(days=30)
today = self.today.strftime('%Y-%m-%d')