Ejemplo n.º 1
0
 def test_concept_adapter(self):
     from pyramid_skosprovider.renderers import concept_adapter
     c = Concept(id=larch['id'],
                 labels=larch['labels'],
                 notes=larch['notes'],
                 sources=larch['sources'],
                 concept_scheme=trees.concept_scheme,
                 matches=larch['matches'])
     request = testing.DummyRequest()
     m = Mock()
     request.skos_registry = m
     request.locale_name = 'nl'
     concept = concept_adapter(c, request)
     self.assertIsInstance(concept, dict)
     self.assertEqual(concept['id'], 1)
     self.assertIn('uri', concept)
     self.assertIsInstance(concept['label'], text_type)
     self.assertIn(concept['type'], 'concept')
     self.assertEqual(len(concept['labels']), 3)
     self._assert_is_labels(concept['labels'])
     assert 'matches' in concept
     assert 0 == len(concept['matches']['broad'])
     assert 0 == len(concept['matches']['narrow'])
     assert 0 == len(concept['matches']['related'])
     assert 0 == len(concept['matches']['exact'])
     assert 1 == len(concept['matches']['close'])
     assert 'subordinate_arrays' in concept
     assert 0 == len(concept['subordinate_arrays'])
     assert 'sources' in concept
     assert 1 == len(concept['sources'])
     assert 'label' in concept
     assert concept['label'] == 'De Lariks'
Ejemplo n.º 2
0
 def test_concept_adapter(self):
     from pyramid_skosprovider.renderers import concept_adapter
     c = Concept(
         id=larch['id'],
         labels=larch['labels'],
         notes=larch['notes'],
         sources=larch['sources'],
         concept_scheme=trees.concept_scheme,
         matches=larch['matches']
     )
     request = testing.DummyRequest()
     m = Mock()
     request.skos_registry = m
     request.locale_name = 'nl'
     concept = concept_adapter(c, request)
     self.assertIsInstance(concept, dict)
     self.assertEqual(concept['id'], 1)
     self.assertIn('uri', concept)
     self.assertIsInstance(concept['label'], text_type)
     self.assertIn(concept['type'], 'concept')
     self.assertEqual(len(concept['labels']), 2)
     self._assert_is_labels(concept['labels'])
     assert 'matches' in concept
     assert 0 == len(concept['matches']['broad'])
     assert 0 == len(concept['matches']['narrow'])
     assert 0 == len(concept['matches']['related'])
     assert 0 == len(concept['matches']['exact'])
     assert 1 == len(concept['matches']['close'])
     assert 'subordinate_arrays' in concept
     assert 0 == len(concept['subordinate_arrays'])
     assert 'sources' in concept
     assert 1 == len(concept['sources'])
     assert 'label' in concept
     assert concept['label'] == 'De Lariks'
Ejemplo n.º 3
0
 def test_concept_adapter_en(self):
     from pyramid_skosprovider.renderers import concept_adapter
     c = Concept(
         id=larch['id'],
         labels=larch['labels'],
         concept_scheme=trees.concept_scheme,
     )
     request = testing.DummyRequest()
     m = Mock()
     request.skos_registry = m
     request.locale_name = 'en'
     concept = concept_adapter(c, request)
     assert 'label' in concept
     assert concept['label'] == 'The Larch'
Ejemplo n.º 4
0
 def test_concept_adapter_en(self):
     from pyramid_skosprovider.renderers import concept_adapter
     c = Concept(
         id=larch['id'],
         labels=larch['labels'],
         concept_scheme=trees.concept_scheme,
     )
     request = testing.DummyRequest()
     m = Mock()
     request.skos_registry = m
     request.locale_name = 'en'
     concept = concept_adapter(c, request)
     assert 'label' in concept
     assert concept['label'] == 'The Larch'