def test_check_uniqueness(self):
     items = [
         {"name": "National", "qcode": "A", "is_active": True},
         {"name": "Domestic Sports", "qcode": "a", "is_active": True},
     ]
     with self.assertRaises(SuperdeskApiError):
         VocabulariesService()._check_uniqueness(items, "qcode")
Ejemplo n.º 2
0
 def test_check_uniqueness_active_only(self):
     items = [{
         "name": "National",
         "qcode": "A",
         "is_active": True
     }, {
         "name": "Domestic Sports",
         "qcode": "A",
         "is_active": False
     }]
     VocabulariesService()._check_uniqueness(items, "qcode")
Ejemplo n.º 3
0
    def test_get_locale_vocabulary(self):
        items = [
            {'is_active': True, 'name': 'FIXME1', 'qcode': 'f', 'subject': '',
             'translations': {'name': {'fr': 'FIXME1-fr', 'es': 'FIXME1-es'}}},
            {'is_active': True, 'name': 'FIXME2', 'qcode': 'f', 'subject': '',
             'translations': {'name': {'fr': 'FIXME2-fr', 'es': 'FIXME2-es'}}}
        ]
        result = VocabulariesService().get_locale_vocabulary(items, 'fr')

        self.assertEqual(result[0]['name'], 'FIXME1-fr')
        self.assertEqual(result[1]['name'], 'FIXME2-fr')
    def test_get_locale_vocabulary(self):
        items = [
            {
                "is_active": True,
                "name": "FIXME1",
                "qcode": "f",
                "subject": "",
                "translations": {"name": {"fr": "FIXME1-fr", "es": "FIXME1-es"}},
            },
            {
                "is_active": True,
                "name": "FIXME2",
                "qcode": "f",
                "subject": "",
                "translations": {"name": {"fr": "FIXME2-fr", "es": "FIXME2-es"}},
            },
        ]
        result = VocabulariesService().get_locale_vocabulary(items, "fr")

        self.assertEqual(result[0]["name"], "FIXME1-fr")
        self.assertEqual(result[1]["name"], "FIXME2-fr")
Ejemplo n.º 5
0
 def test_check_value_of_unique_field(self):
     items = [{'name': 'National', 'is_active': True},
              {'name': 'Domestic Sports', 'qcode': 'A', 'is_active': True}]
     with self.assertRaises(SuperdeskApiError):
         VocabulariesService()._check_uniqueness(items, 'qcode')
Ejemplo n.º 6
0
 def test_check_uniqueness_active_only(self):
     items = [{'name': 'National', 'qcode': 'A', 'is_active': True},
              {'name': 'Domestic Sports', 'qcode': 'A', 'is_active': False}]
     VocabulariesService()._check_uniqueness(items, 'qcode')