Example #1
0
def test_laguage_getter_format():
    language = 'error_one_ok_kwargs = you expected %(expected)s but got %(what_got)s'

    filemock = pmock.Mock()
    filemock.expects(pmock.once()).read().will(pmock.return_value(language))

    lg = LanguageGetter('en-us', file_object=filemock)
    lg.fill_data()

    assert lg.format('error_one_ok_kwargs', expected='Xabba', what_got='Yabba') == u'you expected Xabba but got Yabba'
Example #2
0
def test_laguage_getter_format_args():
    language = 'error_one_ok_args = you expected %s but got %s'

    filemock = pmock.Mock()
    filemock.expects(pmock.once()).read().will(pmock.return_value(language))

    lg = LanguageGetter('en-us', file_object=filemock)
    lg.fill_data()

    assert lg.format('error_one_ok_args', 'X', 'Y') == u'you expected X but got Y'
Example #3
0
def test_laguage_getter_format_raises_args_got_kwargs():
    language = 'error_five_args_got_kwargs = impossible to check %s'

    filemock = pmock.Mock()
    filemock.expects(pmock.once()).read().will(pmock.return_value(language))

    lg = LanguageGetter('en-us', file_object=filemock)
    lg.fill_data()

    @raises(WrongArgumentsError)
    def format_wrong_args_got_kwargs():
        assert lg.format('error_five_args_got_kwargs', what='X') != u'impossible to check X in %s'
    format_wrong_args_got_kwargs()
Example #4
0
def test_laguage_getter_format():
    
    mocker = Mocker()
    
    language = 'error_one_ok_kwargs = you expected %(expected)s but got %(what_got)s'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()
    
        assert lg.format('error_one_ok_kwargs', expected='Xabba', what_got='Yabba') == u'you expected Xabba but got Yabba'
Example #5
0
def test_laguage_getter_format_args():
    
    mocker = Mocker()
    
    language = 'error_one_ok_args = you expected %s but got %s'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()
    
        assert lg.format('error_one_ok_args', 'X', 'Y') == u'you expected X but got Y'
Example #6
0
def test_laguage_getter_format_args():

    mocker = Mocker()

    language = 'error_one_ok_args = you expected %s but got %s'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()

        assert lg.format('error_one_ok_args', 'X',
                         'Y') == u'you expected X but got Y'
Example #7
0
def test_language_getter_get():
    language = 'data1 = something\n' \
               'data2 = something else'

    filemock = pmock.Mock()
    filemock.expects(pmock.once()).read().will(pmock.return_value(language))

    lg = LanguageGetter('en-us', file_object=filemock)
    lg.fill_data()

    assert lg.raw_data == language
    assert 'data' in lg.language_path
    assert lg.language_path.endswith('en-us.txt')
    assert lg.get('data1') == u'something'
    assert lg.get('data2') == u'something else'
    filemock.verify()
Example #8
0
def test_laguage_getter_format():

    mocker = Mocker()

    language = 'error_one_ok_kwargs = you expected %(expected)s but got %(what_got)s'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()

        assert lg.format(
            'error_one_ok_kwargs', expected='Xabba',
            what_got='Yabba') == u'you expected Xabba but got Yabba'
Example #9
0
def test_laguage_getter_format_raises_kwargs_got_args():
    
    mocker = Mocker()
    
    language = 'error_six_kwargs_got_args = impossible to check %(param)s'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()
    
        @raises(WrongArgumentsError)
        def format_wrong_args_got_kwargs():
            assert lg.format('error_six_kwargs_got_args', 'X') != u'impossible to check X in %s'
        format_wrong_args_got_kwargs()
Example #10
0
def test_laguage_getter_format_raises_too_many_args():

    mocker = Mocker()

    language = 'error_two_too_many_args = impossible to check %s'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()

        @raises(WrongArgumentsError)
        def format_wrong_too_many_args():
            assert lg.format('error_two_too_many_args', 'X',
                             '!Y') != u'impossible to check X'

        format_wrong_too_many_args()
Example #11
0
def test_language_getter_get():

    mocker = Mocker()

    language = 'data1 = something\n' \
               'data2 = something else'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()

        assert lg.raw_data == language
        assert 'data' in lg.language_path
        assert lg.language_path.endswith('en-us.txt')
        assert lg.get('data1') == u'something'
        assert lg.get('data2') == u'something else'
Example #12
0
def test_language_getter_get():
    
    mocker = Mocker()
    
    language = 'data1 = something\n' \
               'data2 = something else'

    filemock = mocker.mock()
    filemock.read()
    mocker.result(language)

    with mocker:
        lg = LanguageGetter('en-us', file_object=filemock)
        lg.fill_data()
    
        assert lg.raw_data == language
        assert 'data' in lg.language_path
        assert lg.language_path.endswith('en-us.txt')
        assert lg.get('data1') == u'something'
        assert lg.get('data2') == u'something else'