Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testcase and clean the code base on pylint
- Loading branch information
Showing
17 changed files
with
374 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[flies] | ||
url = http://hudson.englab.bne.redhat.com/flies/ | ||
username = admin | ||
key = b6d7044e9ee3b2447c28fb7c50d86d98 | ||
|
||
[defaults] | ||
debug = false | ||
#errors = true | ||
|
||
[servers] | ||
local.url = http://localhost:8080/flies | ||
local.username = username | ||
local.key = key | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<config xmlns="http://flies.openl10n.net/config/v1/"> | ||
|
||
|
||
<url>http://localhost:8080/flies/</url> | ||
<!-- | ||
<url>http://hudson.englab.bne.redhat.com/flies/</url> | ||
<url>http://translate.jboss.org/flies/</url> | ||
<url>http://localhost:8080/flies/</url> --> | ||
<project>test-project</project> | ||
<project-version>5.4</project-version> | ||
<locales> | ||
<!-- | ||
<locale map-from="de-DE">de</locale> | ||
<locale map-from="es-ES">es</locale> | ||
<locale map-from="fr-FR">fr</locale> | ||
<locale map-from="ja-JP">ja</locale> | ||
<locale map-from="ko-KR">ko</locale> | ||
<locale>pt-BR</locale> | ||
--> | ||
<locale map-from="zh-CN">zh-Hans-CN</locale> | ||
</locales> | ||
</config> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# translation of Acls.po to Traditional Chinese | ||
# translation of Acls.po to | ||
# Copyright (C) 2003, 2007 Free Software Foundation, Inc. | ||
# | ||
# Sarah Wang <sarahs@redhat.com>, 2003. | ||
# Xi HUANG <xhuang@redhat.com>, 2007. | ||
# Chester Cheng <ccheng@redhat.com>, 2007. | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Acls\n" | ||
"Report-Msgid-Bugs-To: http://bugs.kde.org\n" | ||
"POT-Creation-Date: 2001-02-09 01:25+0100\n" | ||
"PO-Revision-Date: 2007-07-11 14:49+1000\n" | ||
"Last-Translator: Chester Cheng <ccheng@redhat.com>\n" | ||
"Language-Team: Traditional Chinese <zh_TW@li.org>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: KBabel 1.11.4\n" | ||
|
||
# EXACT MATCH | ||
#. Tag: title | ||
#: Acls.xml:8 | ||
#, no-c-format | ||
msgid "<title>Access Control Lists</title>" | ||
msgstr "<title>访问存取控制列表</title>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR Free Software Foundation, Inc. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2001-02-09 01:25+0100\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <LL@li.org>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: application/x-xml2pot; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: ENCODING\n" | ||
|
||
#. Tag: title | ||
#: Acls.xml:8 | ||
#, no-c-format | ||
msgid "<title>Access Control Lists</title>" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Flies Python Client | ||
# | ||
# Copyright (c) 2010 Jian Ni <jni@redhat.com> | ||
# Copyright (c) 2010 Red Hat, Inc. | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this program; if not, write to the | ||
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
# Boston, MA 02111-1307 USA | ||
|
||
all__ = ( | ||
"ConfigTest", | ||
) | ||
|
||
import unittest | ||
import sys, os | ||
sys.path.insert(0, os.path.abspath(__file__+"/../..")) | ||
|
||
from zanataclient.parseconfig import ZanataConfig | ||
|
||
|
||
class ConfigTest(unittest.TestCase): | ||
def setUp(self): | ||
self.config = ZanataConfig() | ||
|
||
def test_user_config(self): | ||
self.config.set_userconfig("./flies.ini") | ||
server = self.config.get_server("http://localhost:8080/flies") | ||
user_name = self.config.get_config_value("username", 'servers', server) | ||
apikey = self.config.get_config_value("key", 'servers',server) | ||
self.assertEqual(server, "local") | ||
self.assertEqual(user_name, "username") | ||
self.assertEqual(apikey, "key") | ||
|
||
def test_project_config(self): | ||
project_config = self.config.read_project_config("./flies.xml") | ||
self.assertEqual(project_config['project_url'], "http://localhost:8080/flies/") | ||
self.assertEqual(project_config['project_id'], "test-project") | ||
self.assertEqual(project_config['project_version'], "5.4") | ||
self.assertEqual(project_config['locale_map'], {"zh-CN": "zh-Hans-CN"}) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Zanata Python Client | ||
# | ||
# Copyright (c) 2011 Jian Ni <jni@redhat.com> | ||
# Copyright (c) 2011 Red Hat, Inc. | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this program; if not, write to the | ||
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
# Boston, MA 02111-1307 USA | ||
|
||
all__ = ( | ||
"PublicanUtilityTest", | ||
) | ||
|
||
import unittest | ||
import sys, os | ||
sys.path.insert(0, os.path.abspath(__file__+"/../..")) | ||
|
||
from zanataclient.publicanutil import PublicanUtility | ||
|
||
|
||
class PublicanUtilityTest(unittest.TestCase): | ||
def setUp(self): | ||
self.publican = PublicanUtility() | ||
|
||
def test_strippath(self): | ||
filename = self.publican.strip_path("./pot/test.pot", "./pot") | ||
self.assertEqual(filename, "test") | ||
|
||
def test_potfiletojson(self): | ||
body, filename = self.publican.potfile_to_json("./pot/test.pot", "./pot") | ||
expect = """{"lang": "en-US", "extensions": [{"comment": "SOME DESCRIPTIVE TITLE.\\nCopyright (C) YEAR Free Software Foundation, Inc.\\nFIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\\n", "object-type": "po-header", "entries": [{"value": "PACKAGE VERSION", "key": "Project-Id-Version"}, {"value": "2001-02-09 01:25+0100", "key": "POT-Creation-Date"}, {"value": "YEAR-MO-DA HO:MI+ZONE", "key": "PO-Revision-Date"}, {"value": "FULL NAME <EMAIL@ADDRESS>", "key": "Last-Translator"}, {"value": "LANGUAGE <LL@li.org>", "key": "Language-Team"}, {"value": "1.0", "key": "MIME-Version"}, {"value": "application/x-xml2pot; charset=UTF-8", "key": "Content-Type"}, {"value": "ENCODING", "key": "Content-Transfer-Encoding"}]}], "contentType": "application/x-gettext", "name": "test", "textFlows": [{"lang": "en-US", "content": "<title>Access Control Lists</title>", "extensions": [{"object-type": "comment", "value": "Tag: title", "space": "preserve"}, {"object-type": "pot-entry-header", "references": ["Acls.xml:8"], "flags": ["no-c-format"], "context": "", "extractedComment": ""}], "id": "782f49c4e93c32403ba0b51821b38b90", "revision": 1}]}""" | ||
self.assertEqual(expect, body) | ||
self.assertEqual(filename, "test") | ||
|
||
def test_pofiletojson(self): | ||
body = self.publican.pofile_to_json("./po/test.po") | ||
expect = """{"textFlowTargets": [{"content": "<title>\\u8bbf\\u95ee\\u5b58\\u53d6\\u63a7\\u5236\\u5217\\u8868</title>", "extensions": [{"object-type": "comment", "value": "Tag: title", "space": "preserve"}], "state": "Approved", "resId": "782f49c4e93c32403ba0b51821b38b90"}], "extensions": [{"comment": "translation of Acls.po to Traditional Chinese\\ntranslation of Acls.po to\\nCopyright (C) 2003, 2007 Free Software Foundation, Inc.\\n\\nSarah Wang <sarahs@redhat.com>, 2003.\\nXi HUANG <xhuang@redhat.com>, 2007.\\nChester Cheng <ccheng@redhat.com>, 2007.", "object-type": "po-target-header", "entries": [{"value": "Acls", "key": "Project-Id-Version"}, {"value": "http://bugs.kde.org", "key": "Report-Msgid-Bugs-To"}, {"value": "2001-02-09 01:25+0100", "key": "POT-Creation-Date"}, {"value": "2007-07-11 14:49+1000", "key": "PO-Revision-Date"}, {"value": "Chester Cheng <ccheng@redhat.com>", "key": "Last-Translator"}, {"value": "Traditional Chinese <zh_TW@li.org>", "key": "Language-Team"}, {"value": "1.0", "key": "MIME-Version"}, {"value": "text/plain; charset=UTF-8", "key": "Content-Type"}, {"value": "8bit", "key": "Content-Transfer-Encoding"}, {"value": "KBabel 1.11.4", "key": "X-Generator"}]}], "links": []}""" | ||
self.assertEqual(expect, body) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
''' | ||
Created on May 20, 2011 | ||
@author: jamesni | ||
''' | ||
import unittest | ||
import sys, os | ||
sys.path.insert(0, os.path.abspath(__file__+"/../..")) | ||
|
||
from zanataclient import zanata | ||
|
||
|
||
class ZanataTest(unittest.TestCase): | ||
def setup(self): | ||
pass | ||
|
||
def test_convert_serverversion(self): | ||
server_version = "1.3.3" | ||
version_number = zanata.convert_serverversion(server_version) | ||
self.assertEqual(version_number, 1.3) | ||
|
||
def test_seachfile(self): | ||
path = "./po" | ||
result = zanata.search_file(path, "test.po") | ||
self.assertEqual(result, "./po/test.po") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# | ||
# Flies Python Client | ||
# | ||
# Copyright (c) 2010 Jian Ni <jni@redhat.com> | ||
# Copyright (c) 2010 Red Hat, Inc. | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this program; if not, write to the | ||
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
# Boston, MA 02111-1307 USA | ||
|
||
all__ = ( | ||
"CommandlineTest", | ||
) | ||
|
||
import unittest | ||
import sys, os | ||
from minimock import Mock | ||
sys.path.insert(0, os.path.abspath(__file__+"/../..")) | ||
|
||
from zanataclient.zanatacmd import ZanataCommand | ||
from zanataclient.zanatalib import ZanataResource | ||
from zanataclient.zanatalib.project import Project | ||
|
||
|
||
class CommandlineTest(unittest.TestCase): | ||
def setUp(self): | ||
self.zanatacmd = ZanataCommand() | ||
|
||
def test_list_projects(self): | ||
projects = [] | ||
project_data = {'id':"test-project", 'name':"Test Project", 'type':"IterationProject", 'links':[]} | ||
projects.append(Project(project_data)) | ||
|
||
url = "http://localhost" | ||
zanata = ZanataResource(url) | ||
zanata.projects = Mock(url) | ||
zanata.projects.list.mock_returns = projects | ||
result = self.zanatacmd.list_projects(zanata) | ||
self.assertEqual(result[0].id, 'test-project') | ||
|
||
def test_project_info(self): | ||
pass | ||
|
||
def test_version_info(self): | ||
pass | ||
|
||
def test_create_project(self): | ||
pass | ||
|
||
def test_create_version(self): | ||
pass | ||
|
||
def test_pull_command(self): | ||
pass | ||
|
||
def test_push_command(self): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.