Skip to content

Commit

Permalink
Merge pull request #106 from valaparthvi/partial_match
Browse files Browse the repository at this point in the history
[1LP][RFR] Add partial_match in BootstrapNav is_disabled method
  • Loading branch information
mshriver committed Sep 10, 2019
2 parents 70d2372 + f8525f9 commit be5c98f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/widgetastic_patternfly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ def is_disabled(self, text=None, **kwargs):
"""Check if an item is disabled"""
if text:
# Check if an item is disabled based on the text of that item
if isinstance(text, partial_match):
partial_text = text.item
text = self.browser.element(self.PARTIAL_TEXT.format(txt=quote(partial_text))).text
xpath = self.TEXT_DISABLED.format(txt=quote(text))
elif self.VALID_ATTRS & set(kwargs.keys()):
# Check if an item is disabled based on an attribute, if it is one of the VALID_ATTRS
Expand Down
11 changes: 10 additions & 1 deletion testing/test_bootstrap_nav.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from widgetastic.utils import partial_match
from widgetastic.widget import View
from widgetastic_patternfly import BootstrapNav

Expand All @@ -11,8 +12,16 @@ class TestView(View):
# assert that nav is visible
assert view.nav.is_displayed
# Check if all options are being returned
assert view.nav.all_options == ['ALL (Default)', 'Environment / Dev', 'Environment / Prod', '']
assert view.nav.all_options == [
"ALL (Default)",
"Environment / Dev",
"Environment / Prod",
"Environment / UAT",
"",
]
# assert if currently active(selected) element is being returned correctly
assert view.nav.read() == ['ALL (Default)']
# assert if list has_item
assert view.nav.has_item(text='Environment / Prod')
# assert if partial match works for is_disabled
assert view.nav.is_disabled(text=partial_match("UAT"))
3 changes: 3 additions & 0 deletions testing/testing_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ <h4 class="modal-title" id="myModalLabel">Modal Title</h4>
<li class="">
<a href="#">Environment / Prod</a>
</li>
<li class="disabled">
<a href="#">Environment / UAT</a>
</li>
<li class="">
<a href="#"></a>
</li>
Expand Down

0 comments on commit be5c98f

Please sign in to comment.