[test] Add a little test for concept_value function
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 24 Aug 2017 16:24:04 +0200
changeset 2663 274dcd2aafbf
parent 2662 3572864fe580
child 2666 68c5f87f8677
[test] Add a little test for concept_value function Ensure language priority.
test/test_profile_generation.py
--- a/test/test_profile_generation.py	Thu Aug 24 16:23:36 2017 +0200
+++ b/test/test_profile_generation.py	Thu Aug 24 16:24:04 2017 +0200
@@ -924,6 +924,21 @@
         self.assertEqual(pg.SEDA1XSDExport.concepts_language, 'seda-1')
         self.assertEqual(pg.SEDA02XSDExport.concepts_language, 'seda-02')
 
+    def test_concept_value(self):
+        class concept:
+            labels = {}
+
+        concept.labels['fr'] = 'Bonjour'
+        self.assertEqual(pg._concept_value(concept, 'seda-1'), 'Bonjour')
+        concept.labels['en'] = 'Hello'
+        self.assertEqual(pg._concept_value(concept, 'seda-1'), 'Hello')
+        concept.labels['seda'] = 'hello'
+        self.assertEqual(pg._concept_value(concept, 'seda-1'), 'hello')
+        concept.labels['seda-1'] = 'hello you'
+        self.assertEqual(pg._concept_value(concept, 'seda-1'), 'hello you')
+        concept.labels['seda-2'] = 'good-by'
+        self.assertEqual(pg._concept_value(concept, 'seda-1'), 'hello you')
+
 
 if __name__ == '__main__':
     unittest.main()