def testOne(self): server = ResolveServer() observer = CallTrace(emptyGeneratorMethods=['add']) dna = be( (Observable(), (server, (observer,) ) ) ) server.listResolvables = lambda: [{'items': [{'filter': filterFoafAgents, 'partname': 'foafAgent', 'urls': ['some:url']}], 'identifier': 'urn:some:identifier'}] server._urlopen = lambda url: StringIO("""<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://oas.dev.seecr.nl:8000/static/dummy_foaf_agent"> <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Agent"/> <foaf:name>Pietje Puk</foaf:name> <dc:title>Gewillig slachtoffer</dc:title> </rdf:Description> </rdf:RDF>""") lico(dna.all.process()) addCall, injectCall = observer.calledMethods self.assertEqualsWS("""<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about="http://oas.dev.seecr.nl:8000/static/dummy_foaf_agent"> <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Agent"/> <foaf:name>Pietje Puk</foaf:name> <dc:title>Gewillig slachtoffer</dc:title> </rdf:Description>""", tostring(addCall.kwargs['lxmlNode']))
def testListResolvables(self): server = ResolveServer() observer = CallTrace( emptyGeneratorMethods=['add'], returnValues={'searchRetrieve': ListResolvablesTest_SRU}) dna = be( (Observable(), (server, (observer,) ) ) ) resolvables = list(compose(server.listResolvables())) self.assertEquals(1, len(resolvables)) self.assertEquals("http://oas.dev.seecr.nl/resolve/urn:uuid:5318cf36-1599-4b26-8be9-7f7f673e1a79", resolvables[0]['identifier'])