def test_json_collection(self):
     from pyramid_skosprovider.utils import json_renderer
     c = Collection(
         id=species['id'],
         uri=species['uri'],
         labels=species['labels'],
         notes=species['notes'],
         members=species['members'],
         concept_scheme=trees.concept_scheme
     )
     r = json_renderer({})
     jsonstring = r(c, {})
     coll = json.loads(jsonstring)
     self.assertIsInstance(coll, dict)
     self.assertEqual(coll['id'], 3)
     self.assertEqual(coll['uri'], 'http://python.com/trees/species')
     self.assertIsInstance(coll['label'], text_type)
     self.assertEqual(coll['type'], 'collection')
     self.assertIsInstance(coll['labels'], list)
     self.assertEqual(len(coll['labels']), 2)
     for l in coll['labels']:
         self.assertIsInstance(l, dict)
         self.assertIn('label', l)
         self.assertIn('type', l)
         self.assertIn('language', l)
     self.assertEqual(len(coll['notes']), 1)
     for n in coll['notes']:
         self.assertIsInstance(n, dict)
         self.assertIn('note', n)
         self.assertIn('type', n)
         self.assertIn('language', n)
     assert 'matches' not in coll
 def test_json_concept(self):
     from pyramid_skosprovider.utils import json_renderer
     c = Concept(
         id=larch['id'],
         uri=larch['uri'],
         labels=larch['labels'],
         notes=larch['notes']
     )
     r = json_renderer({})
     jsonstring = r(c, {})
     concept = json.loads(jsonstring)
     self.assertIsInstance(concept, dict)
     self.assertEqual(concept['id'], 1)
     self.assertEqual(concept['uri'], 'http://python.com/trees/larch')
     self.assertIsInstance(concept['label'], text_type)
     self.assertEqual(concept['type'], 'concept')
     self.assertIsInstance(concept['labels'], list)
     self.assertEqual(len(concept['labels']), 2)
     for l in concept['labels']:
         self.assertIsInstance(l, dict)
         self.assertIn('label', l)
         self.assertIn('type', l)
         self.assertIn('language', l)
     self.assertIsInstance(concept['notes'], list)
     self.assertEqual(len(concept['notes']), 1)
     for n in concept['notes']:
         self.assertIsInstance(n, dict)
         self.assertIn('note', n)
         self.assertIn('type', n)
         self.assertIn('language', n)
     self.assertIsInstance(concept['broader'], list)
     self.assertIsInstance(concept['related'], list)
     self.assertIsInstance(concept['narrower'], list)
 def test_json_concept(self):
     from pyramid_skosprovider.utils import json_renderer
     c = Concept(
         id=larch['id'],
         uri=larch['uri'],
         labels=larch['labels'],
         notes=larch['notes'],
         concept_scheme=trees.concept_scheme,
         matches=larch['matches']
     )
     r = json_renderer({})
     jsonstring = r(c, {})
     concept = json.loads(jsonstring)
     self.assertIsInstance(concept, dict)
     self.assertEqual(concept['id'], 1)
     self.assertEqual(concept['uri'], 'http://python.com/trees/larch')
     self.assertIsInstance(concept['label'], text_type)
     self.assertEqual(concept['type'], 'concept')
     self.assertIsInstance(concept['labels'], list)
     self.assertEqual(len(concept['labels']), 2)
     for l in concept['labels']:
         self.assertIsInstance(l, dict)
         self.assertIn('label', l)
         self.assertIn('type', l)
         self.assertIn('language', l)
     self.assertIsInstance(concept['notes'], list)
     self.assertEqual(len(concept['notes']), 1)
     for n in concept['notes']:
         self.assertIsInstance(n, dict)
         self.assertIn('note', n)
         self.assertIn('type', n)
         self.assertIn('language', n)
     self.assertIsInstance(concept['broader'], list)
     self.assertIsInstance(concept['related'], list)
     self.assertIsInstance(concept['narrower'], list)
     assert 'matches' in concept
     for mt in ['broad', 'narrow', 'related', 'close', 'exact']:
         assert mt in concept['matches']
         assert list == type(concept['matches'][mt])
     assert 1 == len(concept['matches']['close'])