|
2 | 2 |
|
3 | 3 | from kindergarten_garden import Garden |
4 | 4 |
|
5 | | - |
6 | 5 | # Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.1 |
7 | 6 |
|
| 7 | + |
8 | 8 | class KindergartenGardenTest(unittest.TestCase): |
9 | | - def test_garden_with_single_student(self): |
| 9 | + def test_partial_garden_garden_with_single_student(self): |
| 10 | + garden = Garden("RC\nGG") |
10 | 11 | self.assertEqual( |
11 | | - Garden("RC\nGG").plants("Alice"), |
12 | | - "Radishes Clover Grass Grass".split()) |
| 12 | + garden.plants("Alice"), ["Radishes", "Clover", "Grass", "Grass"] |
| 13 | + ) |
13 | 14 |
|
14 | | - def test_different_garden_with_single_student(self): |
| 15 | + def test_partial_garden_different_garden_with_single_student(self): |
| 16 | + garden = Garden("VC\nRC") |
15 | 17 | self.assertEqual( |
16 | | - Garden("VC\nRC").plants("Alice"), |
17 | | - "Violets Clover Radishes Clover".split()) |
| 18 | + garden.plants("Alice"), ["Violets", "Clover", "Radishes", "Clover"] |
| 19 | + ) |
18 | 20 |
|
19 | | - def test_garden_with_two_students(self): |
| 21 | + def test_partial_garden_garden_with_two_students(self): |
20 | 22 | garden = Garden("VVCG\nVVRC") |
21 | 23 | self.assertEqual( |
22 | | - garden.plants("Bob"), "Clover Grass Radishes Clover".split()) |
| 24 | + garden.plants("Bob"), ["Clover", "Grass", "Radishes", "Clover"] |
| 25 | + ) |
| 26 | + |
| 27 | + def test_partial_garden_second_student_s_garden(self): |
| 28 | + garden = Garden("VVCCGG\nVVCCGG") |
| 29 | + self.assertEqual(garden.plants("Bob"), ["Clover", "Clover", "Clover", "Clover"]) |
23 | 30 |
|
24 | | - def test_multiple_students_for_the_same_garden_with_three_students(self): |
| 31 | + def test_partial_garden_third_student_s_garden(self): |
25 | 32 | garden = Garden("VVCCGG\nVVCCGG") |
26 | | - self.assertEqual(garden.plants("Bob"), ["Clover"] * 4) |
27 | | - self.assertEqual(garden.plants("Charlie"), ["Grass"] * 4) |
| 33 | + self.assertEqual(garden.plants("Charlie"), ["Grass", "Grass", "Grass", "Grass"]) |
28 | 34 |
|
29 | | - def test_full_garden(self): |
| 35 | + def test_full_garden_first_student_s_garden(self): |
30 | 36 | garden = Garden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV") |
31 | 37 | self.assertEqual( |
32 | | - garden.plants("Alice"), |
33 | | - "Violets Radishes Violets Radishes".split()) |
34 | | - self.assertEqual( |
35 | | - garden.plants("Bob"), "Clover Grass Clover Clover".split()) |
| 38 | + garden.plants("Alice"), ["Violets", "Radishes", "Violets", "Radishes"] |
| 39 | + ) |
| 40 | + |
| 41 | + def test_full_garden_second_student_s_garden(self): |
| 42 | + garden = Garden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV") |
| 43 | + self.assertEqual(garden.plants("Bob"), ["Clover", "Grass", "Clover", "Clover"]) |
| 44 | + |
| 45 | + def test_full_garden_second_to_last_student_s_garden(self): |
| 46 | + garden = Garden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV") |
36 | 47 | self.assertEqual( |
37 | | - garden.plants("Kincaid"), "Grass Clover Clover Grass".split()) |
| 48 | + garden.plants("Kincaid"), ["Grass", "Clover", "Clover", "Grass"] |
| 49 | + ) |
| 50 | + |
| 51 | + def test_full_garden_last_student_s_garden(self): |
| 52 | + garden = Garden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV") |
38 | 53 | self.assertEqual( |
39 | | - garden.plants("Larry"), "Grass Violets Clover Violets".split()) |
| 54 | + garden.plants("Larry"), ["Grass", "Violets", "Clover", "Violets"] |
| 55 | + ) |
40 | 56 |
|
41 | 57 | # Additional tests for this track |
42 | | - def test_disordered_test(self): |
| 58 | + |
| 59 | + def test_students_are_unordered_first_student(self): |
43 | 60 | garden = Garden( |
44 | | - "VCRRGVRG\nRVGCCGCV", |
45 | | - students="Samantha Patricia Xander Roger".split()) |
| 61 | + "VCRRGVRG\nRVGCCGCV", students=["Samantha", "Patricia", "Xander", "Roger"] |
| 62 | + ) |
46 | 63 | self.assertEqual( |
47 | | - garden.plants("Patricia"), |
48 | | - "Violets Clover Radishes Violets".split()) |
| 64 | + garden.plants("Patricia"), ["Violets", "Clover", "Radishes", "Violets"] |
| 65 | + ) |
| 66 | + |
| 67 | + def test_students_are_unordered_last_student(self): |
| 68 | + garden = Garden( |
| 69 | + "VCRRGVRG\nRVGCCGCV", students=["Samantha", "Patricia", "Xander", "Roger"] |
| 70 | + ) |
49 | 71 | self.assertEqual( |
50 | | - garden.plants("Xander"), "Radishes Grass Clover Violets".split()) |
| 72 | + garden.plants("Xander"), ["Radishes", "Grass", "Clover", "Violets"] |
| 73 | + ) |
51 | 74 |
|
52 | 75 |
|
53 | | -if __name__ == '__main__': |
| 76 | +if __name__ == "__main__": |
54 | 77 | unittest.main() |
0 commit comments