Description:
Currently, the calculator program supports operators that accept only two arguments. However, we want to introduce a change that allows for operators with multiple or single arguments. To implement this, we need to validate the operation declarations to ensure they follow the desired #1 format.
Task:
Implement a method to validate operation declarations and ensure they adhere to the required format.
Validation Requirements:
The operation declaration should be a dictionary with a valid tag as the key.
- The value associated with the tag should be a dictionary containing the following keys: "title", "symbol", "args", "action", and "result-name".
- The "title" key should have a non-empty string value.
- The "symbol" key should have a non-empty string value.
- The "args" key should have a tuple value containing at least one non-empty string argument.
- The "action" key should have a callable object assigned.
- The "result-name" key should have a non-empty string value.
Acceptance Criteria:
Implement a method named validate_operation_declaration that takes an operation declaration dictionary and the tag str as input and raise a KeyError with details about the error if any ocures. If its right formated just return None.
The method should validate the operation declaration according to the requirements mentioned above.
If any of the validation requirements fail, the method should provide a clear error message indicating the specific issue encountered.
Write unit tests to verify the correctness of the validate_operation_declaration method.
Ensure the method is properly documented with type hints and descriptive docstrings.
Deliverables:
Description:
Currently, the calculator program supports operators that accept only two arguments. However, we want to introduce a change that allows for operators with multiple or single arguments. To implement this, we need to validate the operation declarations to ensure they follow the desired #1 format.
Task:
Implement a method to validate operation declarations and ensure they adhere to the required format.
Validation Requirements:
The operation declaration should be a dictionary with a valid tag as the key.
Acceptance Criteria:
Implement a method named
validate_operation_declarationthat takes an operation declaration dictionary and the tag str as input and raise aKeyErrorwith details about the error if any ocures. If its right formated just return None.The method should validate the operation declaration according to the requirements mentioned above.
If any of the validation requirements fail, the method should provide a clear error message indicating the specific issue encountered.
Write unit tests to verify the correctness of the validate_operation_declaration method.
Ensure the method is properly documented with type hints and descriptive docstrings.
Deliverables: