Exemple #1
0
def assert_stmts_match(expected_stmts, result_stmts):
    assert set(result_stmts) == set(expected_stmts), pprintdiff(
                        result_stmts,expected_stmts)

    if not base.graph_compare(expected_stmts, result_stmts):
        print 'graph_compare failed'
        ge = base.Graph(expected_stmts)
        gr = base.Graph(result_stmts)
        print pprintdiff(ge._hashtuple(), gr._hashtuple())
        #print 'expected _:2', base.Graph(expected_stmts).vhash('_:2')
        #print 'expected _:1', base.Graph(expected_stmts).vhash('_:1')
        #print 'result _:1', base.Graph(result_stmts).vhash('_:1')
        #print 'result _:2', base.Graph(result_stmts).vhash('_:2')
        assert False
Exemple #2
0
 def testNotifyChangeset(changeset):
     self.notifyChangeset = changeset
     def x(d):
         return ['%s=%s' % (k,v) for k,v in sorted(d.items()) 
                                             if k != 'statements']
     diff = utils.pprintdiff(x(changeset), x(expectedChangeSet))                    
     self.assertEquals(changeset, expectedChangeSet, diff)
Exemple #3
0
    def testSerialize(self):
        model = r'''<urn:sha:ndKxl8RGTmr3uomnJxVdGnWgXuA=> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rx4rdf.sf.net/ns/archive#Contents> .
<urn:sha:ndKxl8RGTmr3uomnJxVdGnWgXuA=> <http://rx4rdf.sf.net/ns/archive#sha1-digest> "ndKxl8RGnTmr3u/omnJxVdGnWgXuA=" .
<urn:sha:ndKxl8RGTmr3uomnJxVdGnWgXuA=> <http://rx4rdf.sf.net/ns/archive#hasContent> " llll"@en-US .
<urn:sha:ndKxl8RGTmr3uomnJxVdGnWgXuA=> <http://rx4rdf.sf.net/ns/archive#content-length> "5"^^http://www.w3.org/2001/XMLSchema#int .
_:_a <http://rx4rdf.sf.net/ns/wiki#name> _:_a .
_:_b <http://rx4rdf.sf.net/ns/wiki#name> _:_b .
#ssss!graph context:add:context:txn:blah
_:_a <http://rx4rdf.sf.net/ns/wiki#name> _:_a .
'''        
        stmts = MemStore(parseRDFFromString(model,'test:', 'ntriples')).getStatements()
        for stype in ['ntriples', 'ntjson', 'pjson', 'mjson', 'yaml', 'rdfxml']:
            if not canWriteFormat(stype):
                print 'warning, can not test serializing %s, dependent library not installed' % stype
                continue
            #print 'stype', stype
            options = {}
            if stype == 'mjson':
                options = dict(blobmax=30)
            json = serializeRDF(stmts, stype, options=options)
            if stype in ['pjson', 'mjson', 'yaml']:
                #don't add the order preserving RDF
                options = dict(addOrderInfo=False)
            else:
                options = {}
            newstmts = list(parseRDFFromString(json,'', stype, options=options))
            stmts.sort()
            newstmts.sort()
            #print 'stmts'
            #print stmts
            #print 'newstmts'
            #print newstmts
            #print 'lenght', len(stmts), len(newstmts)
            self.failUnless(stmts == newstmts, 
                        stype+' failed: '+ pprintdiff(stmts, newstmts ))