コード例 #1
0
def test2():
    """ Form - validation KO """
    o = MyApp()

    assert o.name == 'Foo'
    assert o.age == 5

    editor = MyEditor(o)

    assert o.name == 'Foo'
    assert o.age == 5

    editor.set_values('Bar', '1000')

    # Editor values are changed
    assert editor.name.input == editor.name() == 'Bar'
    assert editor.age.input == editor.age() == '1000'
    assert editor.age.value == 5

    # App values aren't changed
    assert o.name == 'Foo'
    assert o.age == 5

    editor.commit()

    # App values aren't changed
    assert o.name == 'Foo'
    assert o.age == 5
コード例 #2
0
ファイル: test_form.py プロジェクト: nagareproject/core
def test2():
    """ Form - validation KO """
    o = MyApp()

    assert o.name == 'Foo'
    assert o.age == 5

    editor = MyEditor(o)

    assert o.name == 'Foo'
    assert o.age == 5

    editor.set_values('Bar', '1000')

    # Editor values are changed
    assert editor.name.input == editor.name() == 'Bar'
    assert editor.age.input == editor.age() == '1000'
    assert editor.age.value == 5

    # App values aren't changed
    assert o.name == 'Foo'
    assert o.age == 5

    editor.commit()

    # App values aren't changed
    assert o.name == 'Foo'
    assert o.age == 5
コード例 #3
0
def test8():
    """ Form - test string validators - multiple validators """
    editor = MyStringEditor5(MyApp())

    # Validation OK
    editor.set_values('123456')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == '123456'
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == ''
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('1234')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == '1234'
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('123456789')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == '123456789'
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('abcdefg')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == 'abcdefg'
    assert editor.name.value == '123456'
コード例 #4
0
ファイル: test_form.py プロジェクト: nagareproject/core
def test8():
    """ Form - test string validators - multiple validators """
    editor = MyStringEditor5(MyApp())

    # Validation OK
    editor.set_values('123456')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == '123456'
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == ''
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('1234')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == '1234'
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('123456789')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == '123456789'
    assert editor.name.value == '123456'

    # Validation KO
    editor.set_values('abcdefg')
    assert editor.name.error is not None
    assert editor.name.input == editor.name() == 'abcdefg'
    assert editor.name.value == '123456'
コード例 #5
0
def test6():
    """ Form - test string validators - shorter_than """
    editor = MyStringEditor3(MyApp())

    # Validation OK
    editor.set_values('1234')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == '1234'
    assert editor.name.value == '1234'

    # Validation KO
    editor.set_values('123456')
    assert editor.name.error == "test6 - Length must be shorter than 5 characters"
    assert editor.name.input == editor.name() == '123456'
    assert editor.name.value == '1234'
コード例 #6
0
def test5():
    """ Form - test string validators - match """
    editor = MyStringEditor2(MyApp())

    # Validation OK
    editor.set_values('abab')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == 'abab'
    assert editor.name.value == 'abab'

    # Validation KO
    editor.set_values('abrab')
    assert editor.name.error == "test5 - Incorrect format"
    assert editor.name.input == editor.name() == 'abrab'
    assert editor.name.value == 'abab'
コード例 #7
0
def test4():
    """ Form - test string validators - not_empty """
    editor = MyStringEditor1(MyApp())

    # Validation OK
    editor.set_values('abcd')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == 'abcd'
    assert editor.name.value == 'abcd'

    # Validation KO
    editor.set_values('')
    assert editor.name.error == "Can't be empty"
    assert editor.name.input == editor.name() == ''
    assert editor.name.value == 'abcd'
コード例 #8
0
ファイル: test_form.py プロジェクト: nagareproject/core
def test6():
    """ Form - test string validators - shorter_than """
    editor = MyStringEditor3(MyApp())

    # Validation OK
    editor.set_values('1234')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == '1234'
    assert editor.name.value == '1234'

    # Validation KO
    editor.set_values('123456')
    assert editor.name.error == "test6 - Length must be shorter than 5 characters"
    assert editor.name.input == editor.name() == '123456'
    assert editor.name.value == '1234'
コード例 #9
0
ファイル: test_form.py プロジェクト: nagareproject/core
def test5():
    """ Form - test string validators - match """
    editor = MyStringEditor2(MyApp())

    # Validation OK
    editor.set_values('abab')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == 'abab'
    assert editor.name.value == 'abab'

    # Validation KO
    editor.set_values('abrab')
    assert editor.name.error == "test5 - Incorrect format"
    assert editor.name.input == editor.name() == 'abrab'
    assert editor.name.value == 'abab'
コード例 #10
0
ファイル: test_form.py プロジェクト: nagareproject/core
def test4():
    """ Form - test string validators - not_empty """
    editor = MyStringEditor1(MyApp())

    # Validation OK
    editor.set_values('abcd')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == 'abcd'
    assert editor.name.value == 'abcd'

    # Validation KO
    editor.set_values('')
    assert editor.name.error == "Can't be empty"
    assert editor.name.input == editor.name() == ''
    assert editor.name.value == 'abcd'
コード例 #11
0
def test7():
    """ Form - test string validators - length_equal  """
    editor = MyStringEditor4(MyApp())

    # Validation OK
    editor.set_values('12345')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == '12345'
    assert editor.name.value == '12345'

    # Validation KO
    editor.set_values('123456')
    assert editor.name.error == "test7 - Length must be 5 characters"
    assert editor.name.input == editor.name() == '123456'
    assert editor.name.value == '12345'

    # Validation KO
    editor.set_values('1234')
    assert editor.name.error == "test7 - Length must be 5 characters"
    assert editor.name.input == editor.name() == '1234'
    assert editor.name.value == '12345'
コード例 #12
0
ファイル: test_form.py プロジェクト: nagareproject/core
def test7():
    """ Form - test string validators - length_equal  """
    editor = MyStringEditor4(MyApp())

    # Validation OK
    editor.set_values('12345')
    assert editor.name.error is None
    assert editor.name.input == editor.name() == '12345'
    assert editor.name.value == '12345'

    # Validation KO
    editor.set_values('123456')
    assert editor.name.error == "test7 - Length must be 5 characters"
    assert editor.name.input == editor.name() == '123456'
    assert editor.name.value == '12345'

    # Validation KO
    editor.set_values('1234')
    assert editor.name.error == "test7 - Length must be 5 characters"
    assert editor.name.input == editor.name() == '1234'
    assert editor.name.value == '12345'