Пример #1
0
    def test_convertphp_notemplate(self):
        """test convertphp helper without template"""
        posource = '''#: $lang['name']
msgid "value"
msgstr "waarde"
'''
        inputfile = BytesIO(posource.encode())
        outputfile = BytesIO()
        with raises(ValueError):
            po2php.convertphp(inputfile, outputfile, None)
Пример #2
0
    def test_convertphp_notemplate(self):
        """test convertphp helper without template"""
        posource = '''#: $lang['name']
msgid "value"
msgstr "waarde"
'''
        inputfile = wStringIO.StringIO(posource)
        outputfile = wStringIO.StringIO()
        with raises(ValueError):
            po2php.convertphp(inputfile, outputfile, None)
Пример #3
0
    def test_convertphp_empty_template(self):
        """test convertphp helper with empty translation"""
        posource = '''#: $lang['name']
msgid "value"
msgstr ""
'''
        inputfile = BytesIO(posource.encode())
        templatefile = BytesIO(b'')
        outputfile = BytesIO()
        assert po2php.convertphp(inputfile, outputfile, templatefile, False, 100) is False
        assert outputfile.getvalue() == b''
Пример #4
0
    def test_convertphp_empty_template(self):
        """test convertphp helper with empty translation"""
        posource = '''#: $lang['name']
msgid "value"
msgstr ""
'''
        inputfile = wStringIO.StringIO(posource)
        templatefile = wStringIO.StringIO('')
        outputfile = wStringIO.StringIO()
        assert po2php.convertphp(inputfile, outputfile, templatefile, False, 100) is False
        assert outputfile.getvalue() == b''
Пример #5
0
    def test_convertphp(self):
        """test convertphp helper"""
        posource = '''#: $lang['name']
msgid "value"
msgstr "waarde"
'''
        phptemplate = '''$lang['name'] = 'value';
'''
        phpexpected = b'''$lang['name'] = 'waarde';
'''
        inputfile = BytesIO(posource.encode())
        templatefile = BytesIO(phptemplate.encode())
        outputfile = BytesIO()
        assert po2php.convertphp(inputfile, outputfile, templatefile) == 1
        assert outputfile.getvalue() == phpexpected
Пример #6
0
    def test_convertphp(self):
        """test convertphp helper"""
        posource = '''#: $lang['name']
msgid "value"
msgstr "waarde"
'''
        phptemplate = '''$lang['name'] = 'value';
'''
        phpexpected = b'''$lang['name'] = 'waarde';
'''
        inputfile = wStringIO.StringIO(posource)
        templatefile = wStringIO.StringIO(phptemplate)
        outputfile = wStringIO.StringIO()
        assert po2php.convertphp(inputfile, outputfile, templatefile) == 1
        assert outputfile.getvalue() == phpexpected