Esempio n. 1
0
 def test_subject_properties(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {'id': 'the-count', 'name': 'The Count'}
     stmts = list(sv.triplify(data))
     assert len(stmts) == 3, len(stmts)
     subj = [a for a, _, _, _ in stmts]
     assert len(set(subj)) == 1, subj
     assert subj[0] == 'the-count', subj
Esempio n. 2
0
 def test_basic_statement_conversion(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {'name': 'The Count'}
     stmts = list(sv.triplify(data))
     assert len(stmts) == 2, len(stmts)
     subj = [a for a, _, _, _ in stmts]
     assert len(set(subj)) == 1, subj
     assert subj[0].startswith('urn:uuid'), subj
 def test_basic_statement_conversion(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {
         'name': 'The Count'
     }
     stmts = list(sv.triplify(data))
     assert len(stmts) == 2, len(stmts)
     subj = [a for a, _, _, _ in stmts]
     assert len(set(subj)) == 1, subj
     assert subj[0].startswith('urn:uuid'), subj
 def test_subject_properties(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {
         'id': 'the-count',
         'name': 'The Count'
     }
     stmts = list(sv.triplify(data))
     assert len(stmts) == 3, len(stmts)
     subj = [a for a, _, _, _ in stmts]
     assert len(set(subj)) == 1, subj
     assert subj[0] == 'the-count', subj
 def test_nested_object(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {
         'id': 'the-count',
         'name': 'The Count',
         'memberships': [{
             'role': 'Counter',
             'organization': {
                 'name': 'Beans'
             }
         }]
     }
     stmts = list(sv.triplify(data))
     assert len(stmts) == 9, len(stmts)
     subj = [a for a, _, _, _ in stmts]
     assert len(set(subj)) == 3, subj
Esempio n. 6
0
 def test_nested_object(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {
         'id': 'the-count',
         'name': 'The Count',
         'memberships': [{
             'role': 'Counter',
             'organization': {
                 'name': 'Beans'
             }
         }]
     }
     stmts = list(sv.triplify(data))
     assert len(stmts) == 9, len(stmts)
     subj = [a for a, _, _, _ in stmts]
     assert len(set(subj)) == 3, subj
 def test_reverse_objectify(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {
         'id': 'the-count',
         'name': 'The Count',
         'memberships': [{
             'role': 'Counter',
             'organization': {
                 'id': 'beans',
                 'name': 'Beans'
             }
         }]
     }
     stmts = list(sv.triplify(data))
     loader = load_maker(stmts)
     obj = sv.objectify(loader, data['id'], depth=4)
     assert obj['id'] == data['id']
     oname = obj['memberships'][0]['organization']['name']
     dname = obj['memberships'][0]['organization']['name']
     assert oname == dname, obj
Esempio n. 8
0
 def test_reverse_objectify(self):
     sv = StatementsVisitor(self.schema, resolver)
     data = {
         'id':
         'the-count',
         'name':
         'The Count',
         'memberships': [{
             'role': 'Counter',
             'organization': {
                 'id': 'beans',
                 'name': 'Beans'
             }
         }]
     }
     stmts = list(sv.triplify(data))
     loader = load_maker(stmts)
     obj = sv.objectify(loader, data['id'], depth=4)
     assert obj['id'] == data['id']
     oname = obj['memberships'][0]['organization']['name']
     dname = obj['memberships'][0]['organization']['name']
     assert oname == dname, obj