fix: prevent duplicate activities in array and self-referential relat… - #44
fix: prevent duplicate activities in array and self-referential relat…#44pisum-sativum wants to merge 3 commits into
Conversation
|
@kathan-majithia I have done the necessary changes kindly check and merge and kindly provide the tags gssoc and gssoc:approved. |
|
Traceback (most recent call last): Entire trackback should not be displayed. Also provide some test cases to verify your solution. |
…ions (kathan-majithia#44) - Prevent full traceback on validation errors by wrapping main block in try-except - Add unit tests for duplicate activities and self-referential relations checks
@kathan-majithia I have done the necessary changes kindly check and merge with the tags gssoc and gssoc: approved pls. |
|
I checked, but still got same result only. |
86cb5f2 to
eda7fc5
Compare
@kathan-majithia I have done the required changes pls check and merge with gssoc and gssoc:approved tags. |
Description:
Fixes #16
This PR addresses the bug where the library was silently accepting duplicate activity names and self-referential dependencies, which could eventually lead to a
RecursionErrorwhen callingfind_probable_paths().Changes Made:
add_activities_relationsto check for duplicate items within theactivitiesarray parameter itself during the initial validation loop. It now properly raises aValueErrorimmediately rather than attempting to insert invalid structures.add_relationandadd_activities_relationsto ensure a node cannot be set as a predecessor to itself (e.g.,A -> A). If such an attempt is made, it will immediately raise aValueErrorpreventing any self-referential cycles before traversal begins.Testing:
activities = ['A', 'A']safely raises aValueError: Activity 'A' already exists. Duplicate names are not allowed.cpm.add_relation('A', 'A')correctly raises aValueError: Self-referential dependency detected: 'A' cannot be a predecessor of itself.