Skip to content

Commit

Permalink
Merge f3c57de into 9a98784
Browse files Browse the repository at this point in the history
  • Loading branch information
izapolsk committed Jan 24, 2019
2 parents 9a98784 + f3c57de commit e17dc78
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions testing/test_view.py
Expand Up @@ -536,6 +536,32 @@ class FooView(View):
assert view.the_switchable_view.widget.read() == 'footest'


def test_switchable_view_fill(browser):
class MyView(View):
the_reference = Select(id='switchabletesting-select')

the_switchable_view = ConditionalSwitchableView()

@the_switchable_view.register(lambda the_reference: the_reference == 'foo', default=True)
class FooView(View):
widget = Checkbox(id='switchabletesting-3')

@the_switchable_view.register(lambda the_reference: the_reference == 'bar')
class BarView(View):
widget = Checkbox(id='switchabletesting-4')

view = MyView(browser)
view.the_reference.fill('bar')
assert view.the_reference.read() == 'bar'
view.the_switchable_view.widget.fill(True)
assert view.the_switchable_view.widget.read(), "non default not filled"

view.the_reference.fill('foo')
assert view.the_reference.read() == 'foo'
view.the_switchable_view.widget.fill(True)
assert view.the_switchable_view.widget.read(), "default not filled"


def test_switchable_view_without_default_and_unhandled_value(browser):
class MyView(View):
the_reference = Select(id='switchabletesting-select')
Expand Down
2 changes: 2 additions & 0 deletions testing/testing_page.html
Expand Up @@ -144,6 +144,8 @@ <h3>test test</h3>

<h3 id="switchabletesting-1">footest</h3>
<h3 id="switchabletesting-2">bartest</h3>
<input id="switchabletesting-3" type="checkbox" />
<input id="switchabletesting-4" type="checkbox" />

</div>

Expand Down

0 comments on commit e17dc78

Please sign in to comment.