8000
CodSpeed Performance ReportMerging #1169 will not alter performanceComparing Summary
|
0b31ffc
to
7423c24
Compare
categories: ClassVar[list[str]] = ["configuration"] | ||
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show running-config", ofmt="text")] | ||
|
||
class Input(AntaTest.Input): | ||
"""Input model for the VerifyRunningConfigLines test.""" | ||
|
||
regex_patterns: list[RegexString] | ||
"""List of regular expressions.""" | ||
sections: list[RunningConfigSection] = Field(default=[]) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why did you change the default to an empty list? We usually use None
.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The reason behind this choice is to help reduce cognitive complexity. If we were to use None as the default, we would need to add additional conditional checks to verify whether inputs.sections and regex_patterns are provided before using them. This would require extra if statements, particularly before iterating, to avoid errors when attempting to loop over a None value..
By defaulting to an empty list, we can simplify the logic and avoid unnecessary checks.
Please feel free to correct me if I’m mistaken, or share your thoughts—I'm happy to consider any suggestions or improvements.
Thanks! Geetanjali
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok I understand the reason but we should still use None
to be consistent with other tests. Thanks
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agreed @carl-baillargeon, updated test with default value as None
Thanks!
1. section: router bgp 65101, regex_patterns: router-id 10.111.254.1 | ||
2. section: router isis 1 regex_patterns: address-family ipv4 unicast | ||
""" | ||
regex_patterns: list[RegexString] = Field(default=[]) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Same here.
else: | ||
self.result.is_failure("Following patterns were not found: " + ", ".join(failure_msgs)) | ||
re_search = re.compile(pattern, re.IGNORECASE | re.MULTILINE) | ||
if not re_search.search(self.instance_commands[0].text_output): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling self.instance_commands[0].text_output
everytime, you should assign this to a running_config
variable outside of the loops.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Updated Thanks
fd48e94
to
086f1ae
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
|
Description
Enhanced VerifyRunningConfigLines Test Case for multiple matches
Fixes #1134
Inputs:
Checklist:
pre-commit run
)tox -e testenv
)