import pathlib import sys import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) from round_titles import lacks_counts, round_counts, round_findings class Rounds(unittest.TestCase): def test_counts_each_passs_highest_round(self): counts = round_counts(["Answer prose round 1: x", "Answer full scan round 2: y", "Answer full scan round 1: z", "Answer stability: no round", "Answer stabilty round 1: typo", "Answer security round 1: rename round 2: x", "Record the comprehension check: w"]) self.assertEqual((counts["prose"], counts["full scan"], counts["stability"], counts["architecture"], counts["stabilty"], counts["security"]), (1, 2, 0, 0, 1, 1)) def test_counts_a_mis_cased_title_under_its_pass(self): self.assertEqual(round_counts(["Answer Architecture round 4: x", "Answer architecture round 3: y"])["architecture"], 4) def test_counts_a_repeated_round_number_as_a_round_of_its_own(self): self.assertEqual(round_counts(["Answer stability round 3: x", "Answer stability round 3: y", "Answer stability round 2: z", "Answer stability round 1: w"])["stability"], 4) class RoundFindings(unittest.TestCase): def test_sums_the_counts_each_round_title_opens_with(self): self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡; flag a deleted test", "Answer prose round 1: 0 🔴, 3 🟡", "Merge origin/main"]), (1, 5)) def test_knows_no_count_when_a_round_title_or_every_round_lacks_one(self): self.assertIsNone(round_findings(["Answer stability round 1: 1 🔴, 2 🟡; fix", "Answer prose round 1: fix the README"])) self.assertIsNone(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 fix"])) self.assertIsNone(round_findings(["Do the work"])) def test_finds_a_round_title_without_counts(self): self.assertTrue(lacks_counts("Answer stability round 1: fix")) self.assertFalse(lacks_counts("Answer stability round 1: 0 🔴, 1 🟡; fix")) self.assertFalse(lacks_counts("Answer the question")) if __name__ == "__main__": unittest.main()