-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFR] Add regex capability to match_messages #112
Conversation
9297383
to
f3fd98a
Compare
f3fd98a
to
9975bfb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great enhancement Tasos!
@@ -274,25 +274,55 @@ def dismiss(self): | |||
message.dismiss() | |||
|
|||
def match_messages(self, text=None, t=None, partial=False, inverse=False): | |||
""" | |||
Return a list of flash messages matching the specified alert text and type(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
9975bfb
to
957893f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. great enhancement.
if t is not None: | ||
self.logger.info('%s match of the flash message %r of type %r', log_part, text, t) | ||
log_inverse = "inverse " if inverse else "" | ||
log_type = f", type: {t!r}" if msg_type else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mshriver, are we going to stick to py 3.6+ ? I'm about usage of f-strings in public modules
This PR adds the ability to pass a compiled regex as the 'text' parameter for the match_messages, assert_message, and assert_success_message methods of the FlashMessages class.
For example, when testing VM retirement using the 'Time Delay from Now' option, the selected month/week/day/hour time delay values will be added to the date/time at which the page was loaded. The resulting flash message from a successful save is of the form "Retirement date set to 12/19/19 18:31 UTC". But if the time changes from one minute to the next while navigating to the Set Retirement Date page, it is impossible to predict accurately whether the flash message will display a time delay calculated from one or the other minute. Now, with a test like the following,
a single assertion against a range of dates / flash message texts can be performed.
A couple other small changes:
1.) Fixed several typos in which log messages wrote 'Boostrap tree' instead of 'Bootstrap tree'.
2.) Changed the logging in match_messages somewhat to make it clearer and to indicate when the match is actually an inverse match.
3.) Also added a unit test file, test_flashmessages.py, which tests basic functionality of the FlashMessages methods read, assert_no_error, assert_message, assert_success_message, match_messages, and dismiss.