kaizen-ai / kaizenflow

KaizenFlow is a framework for Bayesian reasoning and AI/ML stream computing
GNU General Public License v3.0
110 stars 76 forks source link

KaizenTask1119 Write unit tests for the functions typed_get() and checked_get() #1120

Open mihir1906 opened 1 month ago

mihir1906 commented 1 month ago

Created this PR for the issue #1119.

Changes Made: Added unit tests for typed_get() and checked_get().

Testing:

test_dict.py::Test_typed_get::test1 (0.00 s) PASSED                                                                                                                                                                          [  9%]
test_dict.py::Test_typed_get::test10 (0.00 s) PASSED                                                                                                                                                                         [ 18%]
test_dict.py::Test_typed_get::test11 (0.00 s) PASSED                                                                                                                                                                         [ 27%]
test_dict.py::Test_typed_get::test2 (0.00 s) PASSED                                                                                                                                                                          [ 36%]
test_dict.py::Test_typed_get::test3 (0.00 s) PASSED                                                                                                                                                                          [ 45%]
test_dict.py::Test_typed_get::test4 (0.00 s) PASSED                                                                                                                                                                          [ 54%]
test_dict.py::Test_typed_get::test5 (0.00 s) PASSED                                                                                                                                                                          [ 63%]
test_dict.py::Test_typed_get::test6 (0.00 s) PASSED                                                                                                                                                                          [ 72%]
test_dict.py::Test_typed_get::test7 (0.00 s) PASSED                                                                                                                                                                          [ 81%]
test_dict.py::Test_typed_get::test8 (0.00 s) PASSED                                                                                                                                                                          [ 90%]
test_dict.py::Test_typed_get::test9 (0.00 s) PASSED                                                                                                                                                                          [100%]
test_dict.py::Test_checked_get::test1 (0.00 s) PASSED                                                                                                                                                                        [ 20%]
test_dict.py::Test_checked_get::test2 (0.00 s) PASSED                                                                                                                                                                        [ 40%]
test_dict.py::Test_checked_get::test3 (0.00 s) PASSED                                                                                                                                                                        [ 60%]
test_dict.py::Test_checked_get::test4 (0.00 s) PASSED                                                                                                                                                                        [ 80%]
test_dict.py::Test_checked_get::test5 (0.00 s) PASSED                                                                                                                                                                        [100%]

@samarth9008 @sonaalKant @DanilYachmenev please do let me know incase of any further suggestions/changes.

mihir1906 commented 1 month ago

Lets try to maintain the order of the tests w.r.t the code in the function. Currently I see the tests for expected type in typed_get function are written first however that line is written by the end of the function.

Before that many other tests for other LOCs could have been written. Easy to read and check if all the conditions are covered.

For e.g.: test 6 could be the first one as its the simplest execution of the function.

Lets also check if the test actually adds any value w.r.t the functionality of the function being tested.

I've reordered the tests to follow the function’s code execution flow and ensured each test case is valuable for verifying different aspects of the function. This should improve readability and coverage.

mihir1906 commented 3 weeks ago

@gpsaggese @samarth9008 @DanilYachmenev I just wanted to kindly follow up on this PR and see if you had a chance to review it. If there are any changes or additional details you'd like me to address, I’d be happy to make those adjustments.