예제 #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