def test_remote_content(self): """get widget remote content""" self.sock.send('''{"service": "delicious.com", "params": {"widget": "tag", "request_path": "/tag/widgets", "format":"html"}}\r\n''') resp = TCPServiceResponse(sock_data(self.sock)) #print('resp.content for delicius request: %s' % resp.content) assert resp.content is not None, 'should return html page' assert 'Bookmarks' in resp.content, 'should get from delicous bookmars' assert resp.is_success() == True self.sock.send('''{"service": "workshops", "params": {"widget": "somewidget", "request_path": "/nearme/123/08/2008/50/"}}\r\n''') resp = TCPServiceResponse(self.sock.recv(1024)) assert resp.content == None, 'should return nothing as it doesnt exist' assert resp.is_success() == False
def test_demisauce_registry(self): from hudsucker.registry.demisauce_registry import DemisauceRegistry registry = DemisauceRegistry(Settings) #print registry.config_tostr() sd = registry.load_service(ServiceDefinition('comment',app='demisauce',data={'key':'for_testing'})) #print('sd.base_url: %s' % sd.base_url) #print('config_file: %s' % config_file) #print('demisauce service uri: %s' % Settings.registry_config['source']) assert str(sd.base_url) == Settings.registry_config['source'] json = to_hudsucker_json(sd) print('json: %s' % (json)) self.sock.send('%s\r\n' % json) resp = TCPServiceResponse(self.sock.recv(1024)) print('content: %s' % (resp.content)) assert resp.content is not None assert resp.is_success() == True
def test_no_registry_needed(self): """Test the ability to create fully functional service with no registry""" self.sock.send('''{"app": "delicious.com", "service": "rss_feed_for_test_only", "base_url": "http://feeds.delicious.com", "url_pattern": "/v2/rss/tag/{tag}?count=5", "params": { "format": "xml", "tag": "python" }, "version":"1.1" }\r\n''') resp = TCPServiceResponse(sock_data(self.sock)) #print('resp.content for delicius request: %s' % resp.content) assert resp.content is not None, 'should return rss xml' assert '<channel>' in resp.content, 'should get xml rss' assert resp.is_success() == True