From 9c89870c71183c92b12eb37cfc16666bd441cf09 Mon Sep 17 00:00:00 2001 From: mrossinek Date: Mon, 31 Dec 2018 16:31:17 +0100 Subject: [PATCH] Add unit-tests to verify fix for 1904 --- test/project.t | 39 +++++++++++++++++++++++++++++++++++++++ test/summary.t | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/test/project.t b/test/project.t index 02521e5a1..1f3eabd94 100755 --- a/test/project.t +++ b/test/project.t @@ -481,6 +481,45 @@ class TestBug1627(TestCase): self.assertEqual("mon\n", out) +class TestBug1904(TestCase): + def setUp(self): + """Executed before each test in the class""" + self.t = Task() + + def add_tasks(self): + self.t("add pro:a-b test1") + self.t("add pro:a.b test2") + + def validate_order(self, out): + order = ( + "a", + " b", + "a-b", + ) + + lines = out.splitlines(True) + # position where project names start on the lines list + position = 3 + + for i, proj in enumerate(order): + pos = position + i + + self.assertTrue( + lines[pos].startswith(proj), + msg=("Project '{0}' is not in line #{1} or has an unexpected " + "indentation.{2}".format(proj, pos, out)) + ) + + def test_project_eval(self): + """1904: verify correct order under projects command""" + self.add_tasks() + + code, out, err = self.t("projects") + + self.validate_order(out) + + + if __name__ == "__main__": from simpletap import TAPTestRunner unittest.main(testRunner=TAPTestRunner()) diff --git a/test/summary.t b/test/summary.t index bfd2c8c88..c5255a2f5 100755 --- a/test/summary.t +++ b/test/summary.t @@ -63,6 +63,44 @@ class TestSummaryPercentage(TestCase): self.assertIn("No projects.", out) +class TestBug1904(TestCase): + def setUp(self): + """Executed before each test in the class""" + self.t = Task() + + def add_tasks(self): + self.t("add pro:a-b test1") + self.t("add pro:a.b test2") + + def validate_order(self, out): + order = ( + "a", + " b", + "a-b", + ) + + lines = out.splitlines(True) + # position where project names start on the lines list + position = 3 + + for i, proj in enumerate(order): + pos = position + i + + self.assertTrue( + lines[pos].startswith(proj), + msg=("Project '{0}' is not in line #{1} or has an unexpected " + "indentation.{2}".format(proj, pos, out)) + ) + + def test_project_eval(self): + """1904: verify correct order under summary command""" + self.add_tasks() + + code, out, err = self.t("summary") + + self.validate_order(out) + + if __name__ == "__main__": from simpletap import TAPTestRunner unittest.main(testRunner=TAPTestRunner())