From 6a1835157699efecf7d5e63e9def06e352388f8d Mon Sep 17 00:00:00 2001 From: diligejy Date: Sat, 20 Jan 2024 10:07:13 +0900 Subject: [PATCH] TDD Pandas - [RED][BUG] We introduced a bug that was not spotted by existing tests --- PyCon_PL/Readme.md | 3 ++- PyCon_PL/Test_Driven_Pandas/tests/test_gradebook.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/PyCon_PL/Readme.md b/PyCon_PL/Readme.md index ee664be..516a306 100644 --- a/PyCon_PL/Readme.md +++ b/PyCon_PL/Readme.md @@ -1,4 +1,5 @@ 1. [Grzegorz Kocjan - Test Driven Pandas](https://youtu.be/oaADte_9u6Q) - [Folder](./Test_Driven_Pandas/) - [Link](https://belazy.dev/talks/test-driven-pandas/) - - [Pytest Fixture Ref](https://twpower.github.io/19-about-python-test-fixture) \ No newline at end of file + - [Pytest Fixture Ref](https://twpower.github.io/19-about-python-test-fixture) + - [Typing Module - Optional](https://www.daleseo.com/python-typing/) \ No newline at end of file diff --git a/PyCon_PL/Test_Driven_Pandas/tests/test_gradebook.py b/PyCon_PL/Test_Driven_Pandas/tests/test_gradebook.py index e778b54..1348ea9 100644 --- a/PyCon_PL/Test_Driven_Pandas/tests/test_gradebook.py +++ b/PyCon_PL/Test_Driven_Pandas/tests/test_gradebook.py @@ -67,7 +67,7 @@ def two_students_in_the_same_group() -> pd.DataFrame(): ] return pd.DataFrame(data=students).set_index("NetID") -def test_results_are_grouped_by_student_group_for_students_in_multiple_group(): +def test_results_are_grouped_by_student_group_for_students_in_multiple_groups(): students = [{ "ID" : 1, "Name" : "Doe, John", @@ -76,14 +76,16 @@ def test_results_are_grouped_by_student_group_for_students_in_multiple_group(): "Group" : 1, },{ "ID" : 2, - "Name" : "Alec, Curry", - "NetID" : "AMC53511", + "Name" : "Doe, Second", + "NetID" : "SXD54321", "Email Address" : "ALEC.CURRY@EXAMPLE.EDU", "Group" : 2, }] students_df = pd.DataFrame(data=students).set_index("NetID") result = generate_gradebook(students_df=students_df) assert list(result.keys()) == [1, 2] + assert result[1]['net_id'].tolist() == ['jxd12345'] + assert result[2]['net_id'].tolist() == ['sxd54321'] def test_results_group_contains_students_net_id_lowercase(two_students_in_the_same_group):