Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

62 linhas
2.0 KiB

  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. import webnotes, unittest, os
  4. import webnotes.translate
  5. class TestTranslations(unittest.TestCase):
  6. def test_doctype(self, messages=None):
  7. if not messages:
  8. messages = webnotes.translate.get_messages_from_doctype("Role")
  9. self.assertTrue("Role Name" in messages)
  10. def test_page(self, messages=None):
  11. if not messages:
  12. messages = webnotes.translate.get_messages_from_page("finder")
  13. self.assertTrue("Finder" in messages)
  14. def test_report(self, messages=None):
  15. if not messages:
  16. messages = webnotes.translate.get_messages_from_report("ToDo")
  17. self.assertTrue("Test" in messages)
  18. def test_include_js(self, messages=None):
  19. if not messages:
  20. messages = webnotes.translate.get_messages_from_include_files("webnotes")
  21. self.assertTrue("History" in messages)
  22. def test_server(self, messages=None):
  23. if not messages:
  24. messages = webnotes.translate.get_server_messages("webnotes")
  25. self.assertTrue("Login" in messages)
  26. self.assertTrue("Did not save" in messages)
  27. def test_all_app(self):
  28. messages = webnotes.translate.get_messages_for_app("webnotes")
  29. self.test_doctype(messages)
  30. self.test_page(messages)
  31. self.test_report(messages)
  32. self.test_include_js(messages)
  33. self.test_server(messages)
  34. def test_load_translations(self):
  35. webnotes.translate.clear_cache()
  36. self.assertFalse(webnotes.cache().get_value("lang:de"))
  37. langdict = webnotes.translate.get_full_dict("de")
  38. self.assertEquals(langdict['Row'], 'Reihe')
  39. def test_write_csv(self):
  40. tpath = webnotes.get_pymodule_path("webnotes", "translations", "de.csv")
  41. os.remove(tpath)
  42. webnotes.translate.write_translations_file("webnotes", "de")
  43. self.assertTrue(os.path.exists(tpath))
  44. self.assertEquals(dict(webnotes.translate.read_csv_file(tpath)).get("Row"), "Reihe")
  45. def test_get_dict(self):
  46. webnotes.local.lang = "de"
  47. self.assertEquals(webnotes.get_lang_dict("doctype", "Role").get("Role"), "Rolle")
  48. if __name__=="__main__":
  49. webnotes.connect("site1")
  50. unittest.main()