def testReadJsonComesFromCache(self): """ Do an initial read from JSON file, delete the file and verify that property reads still work because they are served from the cache """ tmp_json = tempfile.NamedTemporaryFile(mode='w', prefix='example', suffix='_en.json', delete=False) fullname = tmp_json.name tmp_json.close() tmppath = os.path.dirname(fullname) name = os.path.basename(fullname) prefix = name.replace('_en.json', '') # make a copy of a properties file copyFile(os.path.join(self.resources_path, 'json_example_en.json'), fullname) # read a value from the properties file options = i18n.read_text_options(tmppath, prefix, "en", "attractAttention", "/") self.assertTrue(options, "attractAttention should be found") self.assertTrue(len(options) > 0, "attractAttention should have at least one option") # delete the temp file os.remove(fullname) # check read of different property from same file still works options = i18n.read_text_options(tmppath, prefix, "en", "goodbye", "/") self.assertTrue(options, "goodbye should be found") self.assertTrue(len(options) > 0, "goodbye should have at least one option")
def testLoadOptionsTextFileFrench(self): options = i18n.read_text_options(self.resources_path, "example", "fr") self.assertEqual(5, len(options))
def testLoadOptionsPropertyFileChinese(self): options = i18n.read_text_options(self.resources_path, "defaults", "zh", "attractAttention", "/") self.assertEqual(5, len(options))
def testLoadOptionsJsonFileFrench(self): options = i18n.read_text_options(self.resources_path, "json_example", "fr", "attractAttention", "/") self.assertEqual(5, len(options))
def testLoadOptionsTextFileChinese(self): options = i18n.read_text_options(self.resources_path, "example", "zh") self.assertEqual(5, len(options))