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)
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)
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''
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''
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
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