Organized
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from redmine_ticket_browse import build_lines, issue_line, parse_id_from_line
|
||||
from redmine_tickets import build_parser, inject_default_sync_command
|
||||
|
||||
|
||||
class BrowseHelpersTest(unittest.TestCase):
|
||||
def test_lines(self):
|
||||
issue = {
|
||||
"id": 42,
|
||||
"status": {"name": "New"},
|
||||
"assigned_to": {"name": "Jason"},
|
||||
"subject": "Foo\tbar\nbaz",
|
||||
"_control_tags": ["spammy"],
|
||||
}
|
||||
line = issue_line(issue)
|
||||
self.assertTrue(line.startswith("42\t"))
|
||||
self.assertIn("Jason", line)
|
||||
self.assertIn("spammy", line)
|
||||
self.assertNotIn("\n", line)
|
||||
self.assertEqual(42, parse_id_from_line(line))
|
||||
self.assertEqual([line], build_lines([issue]))
|
||||
|
||||
def test_cli(self):
|
||||
args = build_parser().parse_args(
|
||||
inject_default_sync_command(
|
||||
["browse", "--where", "assigned_to IS NULL", "--pager", "cat", "--once"]
|
||||
)
|
||||
)
|
||||
self.assertEqual("browse", args.command)
|
||||
self.assertTrue(args.once)
|
||||
self.assertEqual("cat", args.pager)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user