Added TestableInput
This commit is contained in:
@@ -7,7 +7,7 @@ from fasthtml.fastapp import fast_app
|
||||
import myfasthtml.auth.utils
|
||||
from myfasthtml.auth.routes import setup_auth_routes
|
||||
from myfasthtml.auth.utils import create_auth_beforeware, register_user
|
||||
from myfasthtml.core.testclient import MyTestClient
|
||||
from myfasthtml.test.testclient import MyTestClient
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -2,7 +2,7 @@ import pytest
|
||||
from fasthtml.fastapp import fast_app
|
||||
|
||||
from myfasthtml.auth.utils import create_auth_beforeware
|
||||
from myfasthtml.core.testclient import MyTestClient
|
||||
from myfasthtml.test.testclient import MyTestClient
|
||||
|
||||
def test_non_protected_route():
|
||||
app, rt = fast_app()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
from fasthtml.fastapp import fast_app
|
||||
|
||||
from myfasthtml.controls.button import mk_button
|
||||
from myfasthtml.controls.helpers import mk
|
||||
from myfasthtml.core.commands import Command, CommandsManager
|
||||
from myfasthtml.core.testclient import MyTestClient, TestableElement
|
||||
from myfasthtml.test.testclient import MyTestClient, TestableElement
|
||||
|
||||
|
||||
def new_value(value):
|
||||
@@ -24,7 +24,7 @@ def rt(user):
|
||||
|
||||
def test_i_can_trigger_a_command(user):
|
||||
command = Command('test', 'TestingCommand', new_value, "this is my new value")
|
||||
testable = TestableElement(user, mk_button('button', command))
|
||||
testable = TestableElement(user, mk.button('button', command))
|
||||
testable.click()
|
||||
assert user.get_content() == "this is my new value"
|
||||
|
||||
@@ -32,7 +32,7 @@ def test_i_can_trigger_a_command(user):
|
||||
def test_error_is_raised_when_command_is_not_found(user):
|
||||
command = Command('test', 'TestingCommand', new_value, "this is my new value")
|
||||
CommandsManager.reset()
|
||||
testable = TestableElement(user, mk_button('button', command))
|
||||
testable = TestableElement(user, mk.button('button', command))
|
||||
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
testable.click()
|
||||
@@ -44,7 +44,7 @@ def test_i_can_play_a_complex_scenario(user, rt):
|
||||
command = Command('test', 'TestingCommand', new_value, "this is my new value")
|
||||
|
||||
@rt('/')
|
||||
def get(): return mk_button('button', command)
|
||||
def get(): return mk.button('button', command)
|
||||
|
||||
user.open("/")
|
||||
user.should_see("button")
|
||||
|
||||
@@ -2,9 +2,9 @@ import pytest
|
||||
from fastcore.basics import NotStr
|
||||
from fasthtml.components import *
|
||||
|
||||
from myfasthtml.core.matcher import matches, StartsWith, Contains, DoesNotContain, Empty, DoNotCheck, ErrorOutput, \
|
||||
from myfasthtml.test.matcher import matches, StartsWith, Contains, DoesNotContain, Empty, DoNotCheck, ErrorOutput, \
|
||||
ErrorComparisonOutput
|
||||
from myfasthtml.core.testclient import MyFT
|
||||
from myfasthtml.test.testclient import MyFT
|
||||
|
||||
|
||||
@pytest.mark.parametrize('actual, expected', [
|
||||
|
||||
@@ -2,7 +2,7 @@ import pytest
|
||||
from fasthtml.components import Div
|
||||
from fasthtml.fastapp import fast_app
|
||||
|
||||
from myfasthtml.core.testclient import MyTestClient, TestableElement, TestableForm
|
||||
from myfasthtml.test.testclient import MyTestClient, TestableElement, TestableForm
|
||||
|
||||
|
||||
class TestMyTestClientOpen:
|
||||
|
||||
@@ -2,14 +2,14 @@ import pytest
|
||||
from fasthtml.components import Div
|
||||
from fasthtml.fastapp import fast_app
|
||||
|
||||
from myfasthtml.core.testclient import MyTestClient, TestableElement, MyFT
|
||||
from myfasthtml.test.testclient import MyTestClient, TestableElement, MyFT
|
||||
|
||||
|
||||
def test_i_can_create_testable_element_from_ft():
|
||||
ft = Div("hello world", id="test")
|
||||
testable_element = TestableElement(None, ft)
|
||||
|
||||
assert testable_element.ft == ft
|
||||
assert testable_element.my_ft == MyFT('div', {'id': 'test'})
|
||||
assert testable_element.html_fragment == '<div id="test">hello world</div>'
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ def test_i_can_create_testable_element_from_str():
|
||||
ft = '<div id="test">hello world</div>'
|
||||
testable_element = TestableElement(None, ft)
|
||||
|
||||
assert testable_element.ft == MyFT('div', {'id': 'test'})
|
||||
assert testable_element.my_ft == MyFT('div', {'id': 'test'})
|
||||
assert testable_element.html_fragment == '<div id="test">hello world</div>'
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def test_i_can_create_testable_element_from_beautifulsoup_element():
|
||||
tag = BeautifulSoup(ft, 'html.parser').div
|
||||
testable_element = TestableElement(None, tag)
|
||||
|
||||
assert testable_element.ft == MyFT('div', {'id': 'test'})
|
||||
assert testable_element.my_ft == MyFT('div', {'id': 'test'})
|
||||
assert testable_element.html_fragment == '<div id="test">hello world</div>'
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
from fasthtml.fastapp import fast_app
|
||||
|
||||
from myfasthtml.core.testclient import TestableForm, MyTestClient
|
||||
from myfasthtml.test.testclient import TestableForm, MyTestClient
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user