-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regex capability to match_messages
- Loading branch information
Showing
3 changed files
with
156 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import re | ||
from collections import namedtuple | ||
|
||
from widgetastic.widget import View | ||
from widgetastic_patternfly import FlashMessages | ||
|
||
Message = namedtuple('Message', 'text type') | ||
|
||
MSGS = [Message('Retirement date set to 12/31/19 15:55 UTC', 'success'), | ||
Message('Retirement date removed', 'success'), | ||
Message('All changes have been reset', 'warning'), | ||
Message('Set/remove retirement date was cancelled by the user', 'success'), | ||
Message('Retirement initiated for 1 VM and Instance from the CFME Database', 'success')] | ||
|
||
|
||
def test_flashmessage(browser): | ||
class TestView(View): | ||
flash = FlashMessages('.//div[@id="flash_msg_div"]') | ||
|
||
view = TestView(browser) | ||
msgs = view.flash.read() | ||
assert len(msgs) == len(MSGS) | ||
for i in range(len(msgs)): | ||
assert msgs[i] == MSGS[i].text | ||
|
||
view.flash.assert_no_error() | ||
|
||
# regex match | ||
t = re.compile('^Retirement') | ||
view.flash.assert_message(t) | ||
view.flash.assert_success_message(t) | ||
|
||
# partial match | ||
t = 'etirement' | ||
view.flash.assert_message(t, partial=True) | ||
view.flash.assert_success_message(t, partial=True) | ||
|
||
# inverse match | ||
t = 'This message does not exist' | ||
assert not view.flash.match_messages(t) | ||
assert view.flash.match_messages(t, inverse=True) | ||
|
||
view.flash.dismiss() | ||
assert not view.flash.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters