Skip to content

Commit 5c80e82

Browse files
laumannarthurzam
authored andcommitted
pkgdev mask: Add tests for -b/--bug
Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
1 parent 135ddb3 commit 5c80e82

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/scripts/test_pkgdev_mask.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,36 @@ def test_last_rites(self):
199199
cat/pkg
200200
""")
201201
self.masks_path.write_text("") # Reset the contents of package.mask
202+
203+
def test_mask_bugs(self):
204+
removal_date = self.today + timedelta(days=30)
205+
today = self.today.strftime('%Y-%m-%d')
206+
removal = removal_date.strftime('%Y-%m-%d')
207+
for bflag in ('-b', '--bug'):
208+
for (bug_nums, expected) in [
209+
(['42'], 'Bug #42'),
210+
(['42', '43'], 'Bugs #42, #43'),
211+
]:
212+
args = []
213+
for bug_num in bug_nums:
214+
args += [bflag, bug_num]
215+
with os_environ(EDITOR="sed -i '1s/$/mask comment/'"), \
216+
patch('sys.argv', self.args + ['cat/pkg'] + args), \
217+
pytest.raises(SystemExit), \
218+
chdir(pjoin(self.repo.path)):
219+
self.script()
220+
221+
assert self.masks_path.read_text() == textwrap.dedent(f"""\
222+
# First Last <first.last@email.com> ({today})
223+
# mask comment
224+
# {expected}
225+
cat/pkg
226+
""")
227+
self.masks_path.write_text("") # Reset the contents of package.mask
228+
229+
def test_mask_bug_bad(self, capsys, tool):
230+
for (arg, expected) in [('-1', 'must be >= 1'), ('foo', 'invalid integer value')]:
231+
with pytest.raises(SystemExit):
232+
tool.parse_args(['mask', '--bug', arg])
233+
out, err = capsys.readouterr()
234+
assert err.strip() == f'pkgdev mask: error: argument -b/--bug: {expected}'

0 commit comments

Comments
 (0)