コード例 #1
0
ファイル: test_form.py プロジェクト: apoirier/test
def test6():
    """ Form - test string validators - shorter_than """
    o = MyApp()

    app = component.Component(o, model=None)

    editor = MyStringEditor3(app())
    call(app, editor)

    # Validation KO
    editor.setValues('123456', app)
    assert editor.name.error == "test6 - Length must be shorter than 5 characters"

    editor.setValues('1234', app)
    assert editor.name.error is None
コード例 #2
0
ファイル: test_form.py プロジェクト: apoirier/test
def test5():
    """ Form - test string validators - match """
    o = MyApp()

    app = component.Component(o, model=None)

    editor = MyStringEditor2(app())
    call(app, editor)

    # Validation KO
    editor.setValues('abrab', app)
    assert editor.name.error == "test5 - Incorrect format"

    editor.setValues('abab', app)
    assert editor.name.error is None
コード例 #3
0
ファイル: test_form.py プロジェクト: apoirier/test
def test4():
    """ Form - test string validators - not_empty """
    o = MyApp()

    app = component.Component(o, model=None)

    editor = MyStringEditor1(app())
    call(app, editor)

    # Validation KO
    editor.setValues('', app)
    assert editor.name.error == "Can't be empty"

    editor.setValues('abcd', app)
    assert editor.name.error is None
コード例 #4
0
ファイル: test_form.py プロジェクト: apoirier/test
def test1():
    """ Form - validation OK """
    o = MyApp()

    app = component.Component(o, model=None)
    assert app().name == 'Foo'
    assert app().age  == 5

    editor = MyEditor(app())

    call(app, editor)
    assert app().name() == 'Foo'
    assert app().age()  == 5
    assert o.name == 'Foo'
    assert o.age  == 5

    # Validation OK
    editor.setValues('Bar', 4, app)
    assert o.name == 'Bar'
    assert o.age  == 4
コード例 #5
0
ファイル: test_form.py プロジェクト: apoirier/test
def test3():
    """ Form - validation KO & Cancel """
    o = MyApp()

    app = component.Component(o, model=None)

    editor = MyEditor(app())
    call(app, editor)

    # Validation KO
    editor.setValues('Bar', 1000, app)
    # Editor values changes
    assert app().name() == 'Bar'
    assert app().age()  == 1000
    # App values doesn't changes
    assert o.name == 'Foo'
    assert o.age  == 5

    # Cancel
    app.answer()
    assert o.name == 'Foo'
    assert o.age  == 5
コード例 #6
0
ファイル: test_form.py プロジェクト: apoirier/test
def test8():
    """ Form - test string validators - multiple validators """
    o = MyApp()

    app = component.Component(o, model=None)

    editor = MyStringEditor5(app())
    call(app, editor)

    # Validation KO
    editor.setValues('', app)
    assert editor.name.error is not None

    editor.setValues('1234', app)
    assert editor.name.error is not None

    editor.setValues('123456789', app)
    assert editor.name.error is not None

    editor.setValues('abcdefg', app)
    assert editor.name.error is not None

    editor.setValues('123456', app)
    assert editor.name.error is None
コード例 #7
0
ファイル: test_form.py プロジェクト: apoirier/test
def test7():
    """ Form - test string validators - length_equal  """
    o = MyApp()

    app = component.Component(o, model=None)

    editor = MyStringEditor4(app())
    call(app, editor)

    # Validation KO
    editor.setValues('123456', app)
    assert editor.name.error == "test7 - Length must be 5 characters"

    editor.setValues('1234', app)
    assert editor.name.error == "test7 - Length must be 5 characters"

    editor.setValues('12345', app)
    assert editor.name.error is None