def test_simple_structure(self): """Test to read and create the proper structure.""" catalog = Catalog("test") catalog.read_YAML(SIMPLE_DOC) self.assertEqual(catalog.messages, { 'file': u'Fichier', 'edit': u'Édition', 'view': u'Affichage', 'greeting': 'Bienvenue, {name} !', 'connection.connected': u'Connecté', 'connection.connecting': u'Connexion en cours', 'connection.error': u'Connexion impossible', })
def test_write_dictionary(self): """Test to read and retrive the nested structure.""" catalog = Catalog("test") catalog.read_YAML(SIMPLE_DOC) dictionary = catalog.write_dictionary() self.assertEqual(dictionary, { 'file': u'Fichier', 'edit': u'Édition', 'view': u'Affichage', 'greeting': 'Bienvenue, {name} !', 'connection': { 'connected': u'Connecté', 'connecting': u'Connexion en cours', 'error': u'Connexion impossible', }, })
def test_retrieve_plural(self): """Test to retrieve the proper message using count indicators.""" catalog = Catalog("test") catalog.read_YAML(PLURAL_DOC) self.assertEqual(catalog.retrieve("emails", 0), "You have no email") self.assertEqual(catalog.retrieve("emails", 1), "Well, you have one email") self.assertEqual(catalog.retrieve("emails", 2), "You only have 2 emails") self.assertEqual(catalog.retrieve("emails", 3), "You only have 3 emails") self.assertEqual(catalog.retrieve("emails", 5), "Wow, you have 5 emails") self.assertEqual(catalog.retrieve("emails", 6), "Wow, you have 6 emails")
def test_retrieve(self): """Test to retrieve the proper message from a catalog.""" catalog = Catalog("test") catalog.read_YAML(SIMPLE_DOC) self.assertEqual(catalog.retrieve("view"), "Affichage") self.assertEqual(catalog.retrieve("connection.error"), "Connexion impossible") self.assertEqual(catalog.retrieve("greeting", name="Jeanne"), "Bienvenue, Jeanne !")