|
1 | 1 | import os |
| 2 | +import sys |
2 | 3 | import textwrap |
3 | 4 | from datetime import datetime, timedelta, timezone |
4 | 5 | from functools import partial |
@@ -83,6 +84,18 @@ def test_targets(self, repo, make_git_repo, capsys, tool): |
83 | 84 | options, _ = tool.parse_args(['mask', 'cat/pkg']) |
84 | 85 | assert options.atoms == [atom_cls('cat/pkg')] |
85 | 86 |
|
| 87 | + def test_email_not_rites(self, repo, make_git_repo, capsys, tool): |
| 88 | + git_repo = make_git_repo(repo.location) |
| 89 | + |
| 90 | + # masked pkg |
| 91 | + repo.create_ebuild('cat/pkg-0') |
| 92 | + git_repo.add_all('cat/pkg-0') |
| 93 | + with pytest.raises(SystemExit), \ |
| 94 | + chdir(repo.location): |
| 95 | + tool.parse_args(['mask', '--email', 'cat/pkg']) |
| 96 | + _, err = capsys.readouterr() |
| 97 | + assert err.strip() == "pkgdev mask: error: last rites required for email support" |
| 98 | + |
86 | 99 |
|
87 | 100 | class TestPkgdevMask: |
88 | 101 |
|
@@ -202,6 +215,31 @@ def test_last_rites(self): |
202 | 215 | """) |
203 | 216 | self.masks_path.write_text("") # Reset the contents of package.mask |
204 | 217 |
|
| 218 | + @pytest.mark.skipif(sys.platform == "darwin", reason="no xdg-email on mac os") |
| 219 | + def test_last_rites_with_email(self, tmp_path): |
| 220 | + output_file = tmp_path / 'mail.txt' |
| 221 | + for rflag in ('-r', '--rites'): |
| 222 | + with os_environ(EDITOR="sed -i '1s/$/mask comment/'", MAILER=f"> {output_file} echo"), \ |
| 223 | + patch('sys.argv', self.args + ['cat/pkg', rflag, '--email']), \ |
| 224 | + pytest.raises(SystemExit), \ |
| 225 | + chdir(pjoin(self.repo.path)): |
| 226 | + self.script() |
| 227 | + out = output_file.read_text() |
| 228 | + assert 'mailto:gentoo-dev-announce@lists.gentoo.org' in out |
| 229 | + |
| 230 | + self.masks_path.write_text("") # Reset the contents of package.mask |
| 231 | + |
| 232 | + @pytest.mark.skipif(sys.platform == "darwin", reason="no xdg-email on mac os") |
| 233 | + def test_last_email_bad_mailer(self, capsys): |
| 234 | + for rflag in ('-r', '--rites'): |
| 235 | + with os_environ(EDITOR="sed -i '1s/$/mask comment/'", MAILER="false"), \ |
| 236 | + patch('sys.argv', self.args + ['cat/pkg', rflag, '--email']), \ |
| 237 | + pytest.raises(SystemExit), \ |
| 238 | + chdir(pjoin(self.repo.path)): |
| 239 | + self.script() |
| 240 | + _, err = capsys.readouterr() |
| 241 | + assert err.strip() == "pkgdev mask: error: failed opening email composer" |
| 242 | + |
205 | 243 | def test_mask_bugs(self): |
206 | 244 | removal_date = self.today + timedelta(days=30) |
207 | 245 | today = self.today.strftime('%Y-%m-%d') |
|
0 commit comments