Ejemplo n.º 1
0
 def test_add_language_already_exists(self, side_effect):
     i18n_path = self.core_dir + os.sep + 'i18n'
     os.mkdir(i18n_path)
     open(i18n_path + os.sep + 'fr_FR.json', 'a').close()
     Jeedom.add_language(self.plugin_dir)
     self.assertTrue(os.path.exists(i18n_path + os.sep + 'fr_FR.json'))
     self.assertTrue(os.path.exists(i18n_path + os.sep + 'ee_EE.json'))
Ejemplo n.º 2
0
 def test_add_language_with_misstakes(self, side_effect):
     i18n_path = self.core_dir + os.sep + 'i18n'
     os.mkdir(i18n_path)
     Jeedom.add_language(self.plugin_dir)
     self.assertFalse(os.path.exists(i18n_path + os.sep + 'fr.json'))
     self.assertFalse(os.path.exists(i18n_path + os.sep + 'french.json'))
     self.assertFalse(os.path.exists(i18n_path + os.sep + 'FR.json'))
     self.assertFalse(os.path.exists(i18n_path + os.sep + 'FR_FR.json'))
     self.assertTrue(os.path.exists(i18n_path + os.sep + 'en_US.json'))
Ejemplo n.º 3
0
 def test_is_valid_18n_name_valid_bad(self):
     result = Jeedom.is_valid_i18n_name('fra_FR')
     self.assertFalse(result)
     result = Jeedom.is_valid_i18n_name('fr_fr')
     self.assertFalse(result)
     result = Jeedom.is_valid_i18n_name('fr_FRA')
     self.assertFalse(result)
     result = Jeedom.is_valid_i18n_name('frFR')
     self.assertFalse(result)
     result = Jeedom.is_valid_i18n_name('1')
     self.assertFalse(result)
Ejemplo n.º 4
0
 def test_scan_for_strings(self):
     result = Jeedom.scan_for_strings(self.plugin_dir)
     self.assertEqual(self.file_to_test2_path, result[0]['file_path'])
     self.assertIn('translate', result[0]['items'])
     self.assertIn('superb', result[0]['items'])
     self.assertEqual(2, len(result[0]['items']))
     self.assertEqual(self.file_to_test3_path, result[1]['file_path'])
     self.assertIn('Another', result[1]['items'])
     self.assertIn('content', result[1]['items'])
     self.assertIn('Final', result[1]['items'])
     self.assertEqual(3, len(result[1]['items']))
Ejemplo n.º 5
0
 def test_merge_i18n_json_without_initial_data(self):
     result = Jeedom.merge_i18n_json(self.plugin_dir, {}, [
         {
             'file_path': 'file1.php',
             'items': ['Item1', 'Item2']
         },
         {
             'file_path': 'core/file2.php',
             'items': ['Bim', 'Bam', 'Boum']
         }])
     self.assertIn('plugins/PluginName/file1.php', result.keys())
     self.assertIn('Item1', result[
         'plugins/PluginName/file1.php'].keys())
     self.assertIn('plugins/PluginName/core/file2.php', result.keys())
     self.assertIn('Bim', result[
         'plugins/PluginName/core/file2.php'].keys())
Ejemplo n.º 6
0
 def test_merge_i18n_json_with_initial_data(self):
     initial_data = {'plugins/PluginName/file1.php': {'Item1': 'Item1'}}
     result_data = [{'file_path': 'file1.php',
                     'items': ['Item1', 'Item2']},
                    {
                        'file_path': 'core/file2.php',
                        'items': ['Bim',
                                  'Bam',
                                  'Boum']
                    }]
     result = Jeedom.merge_i18n_json('PluginName', initial_data, result_data)
     self.assertIn('plugins/PluginName/file1.php', result.keys())
     self.assertIn('Item2', result[
         'plugins/PluginName/file1.php'].keys())
     self.assertIn('plugins/PluginName/core/file2.php', result.keys())
     self.assertIn('Bam', result[
         'plugins/PluginName/core/file2.php'].keys())
Ejemplo n.º 7
0
 def test_scan_file_from_string_with_strings_to_translate(self):
     result = Jeedom.scan_file_for_strings(self.file_to_test2_path)
     self.assertEqual(result, ['superb', 'translate'])
Ejemplo n.º 8
0
 def test_scan_file_from_string_without_string_to_translate(self):
     result = Jeedom.scan_file_for_strings(self.file_to_test1_path)
     self.assertEqual(result, [])
Ejemplo n.º 9
0
 def test_is_valid_18n_name_valid_good(self):
     result = Jeedom.is_valid_i18n_name('fr_FR')
     self.assertTrue(result)
     result = Jeedom.is_valid_i18n_name('en_US')
     self.assertTrue(result)
Ejemplo n.º 10
0
 def test_get_18n_path(self):
     result = Jeedom.get_i18n_path(self.plugin_dir)
     self.assertEqual(self.core_dir + os.sep + 'i18n', result)
Ejemplo n.º 11
0
 def test_transform_path_to_i18n_path(self):
     result = Jeedom.transform_path_to_i18n_path(
         self.plugin_dir, self.file_to_test2_path)
     self.assertEqual(result,
                      'plugins/PluginName/core/file_to_test2.php')
Ejemplo n.º 12
0
 def test_add_language(self, side_effect):
     i18n_path = self.core_dir + os.sep + 'i18n'
     os.mkdir(i18n_path)
     Jeedom.add_language(self.plugin_dir)
     self.assertTrue(os.path.exists(i18n_path + os.sep + 'fr_FR.json'))
Ejemplo n.º 13
0
 def test_ask_for_i18n_folder_creation_n(self, side_effect):
     i18n_path = self.test_dir + os.sep + 'i18n'
     Jeedom.ask_for_i18n_folder_creation(i18n_path)
     self.assertFalse(os.path.exists(i18n_path))