本文整理汇总了Python中restfulie.Restfulie类的典型用法代码示例。如果您正苦于以下问题:Python Restfulie类的具体用法?Python Restfulie怎么用?Python Restfulie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Restfulie类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.video_granulate_service = Restfulie.at("http://localhost:8885/").auth('test', 'test').as_('application/json')
self.sam = Restfulie.at("http://localhost:8888/").auth('test', 'test').as_('application/json')
self.uid_list = []
input_video = open(join(FOLDER_PATH,'input','working_google.flv')).read()
self.b64_encoded_video = b64encode(input_video)
开发者ID:nsi-iff,项目名称:videogranulate_buildout,代码行数:7,代码来源:testVideoGranulate.py
示例2: testAuthentication
def testAuthentication(self):
""" Test if the server is authenticating correctly """
sam_with_non_existing_user = Restfulie.at("http://localhost:8888/").as_("application/json").auth('dont', 'exists')
result = sam_with_non_existing_user.post(value='test')
self.assertEquals(result.code, "401")
sam_with_non_existing_user = Restfulie.at("http://localhost:8888/").as_("application/json").auth('test', 'wrongpassword')
result = sam_with_non_existing_user.post(value='test')
self.assertEquals(result.code, "401")
开发者ID:nsi-iff,项目名称:sam_buildout,代码行数:9,代码来源:testSAM.py
示例3: setUp
def setUp(self):
self.video_convert_service = Restfulie.at("http://localhost:8884/").auth('test', 'test').as_('application/json')
self.sam = Restfulie.at("http://localhost:8888/").auth('test', 'test').as_('application/json')
self.uid_list = []
input_video = open(join(FOLDER_PATH,'input','rubik.flv')).read()
self.b64_encoded_video = b64encode(input_video)
response = self.video_convert_service.post(video=self.b64_encoded_video, filename='video1.flv', callback='http://localhost:8887/').resource()
self.video_key = response.key
self.uid_list.append(self.video_key)
开发者ID:nsi-iff,项目名称:videoconvert_buildout,代码行数:10,代码来源:testPerformanceVideoConvert.py
示例4: test_extraction_with_document_stored_in_SAM
def test_extraction_with_document_stored_in_SAM(self):
pdf = open(join(FOLDER_PATH, 'teste.pdf')).read()
pdf64 = b64encode(pdf)
sam = Restfulie.at('http://0.0.0.0:8888/').auth('test', 'test').as_('application/json')
resource = sam.put(value={'file':pdf64, 'filename':'teste.pdf'}).resource()
doc_key = resource.key
service = Restfulie.at("http://localhost:8887/").auth('test', 'test').as_('application/json')
response = service.post(doc_key=doc_key, filename='teste.pdf')
sleep(5)
response = service.get(key=doc_key, metadata=True).resource()
metadata_key = response.metadata_key
metadata_key |should_not| equal_to(None)
开发者ID:nsi-iff,项目名称:metadataservice_buildout,代码行数:12,代码来源:testMetadataService.py
示例5: it_should_allow_posting_as_xml
def it_should_allow_posting_as_xml(self):
uri = 'http://coolresource/post-here'
content = {'item': {'name': 'something'}}
encoded_content = Dummy()
with Stub() as urlencode:
from urllib import urlencode
urlencode({'content': "<item><name>something</name></item>"}) >> encoded_content
with Mock() as urlopen:
from urllib2 import urlopen
urlopen(uri, encoded_content)
Restfulie.at(uri).as_('application/xml').post(content)
urlopen.validate()
开发者ID:viniciuschagas,项目名称:restfulie-python,代码行数:12,代码来源:entry_point_post_spec.py
示例6: test_callback_extraction_service
def test_callback_extraction_service(self):
pdf = open(join(FOLDER_PATH, 'teste.pdf')).read()
pdf64 = b64encode(pdf)
pdf64 = "dasdasih"
sam = Restfulie.at('http://0.0.0.0:8888/').auth('test', 'test').as_('application/json')
resource = sam.put(value={'file':pdf64, 'filename':'teste.pdf'}).resource()
doc_key = resource.key
service = Restfulie.at("http://localhost:8887/").auth('test', 'test').as_('application/json')
response = service.post(doc_key=doc_key, filename='teste.pdf', callback_url='http://localhost:8886/', verb='POST')
sleep(3)
callback_log = open('/home/joao/git/metadataservice_buildout/twistd.log').read()
(doc_key in callback_log) |should| equal_to(True)
开发者ID:nsi-iff,项目名称:metadataservice_buildout,代码行数:12,代码来源:testMetadataService.py
示例7: it_should_allow_posting_as_json
def it_should_allow_posting_as_json(self):
uri = 'http://coolresource/post-here'
content = {"just": "testing"}
encoded_content = Dummy()
with Mock() as dumps:
from json import dumps
dumps(content) >> encoded_content
with Mock() as urlopen:
from urllib2 import urlopen
urlopen(uri, encoded_content)
Restfulie.at(uri).as_('application/json').post(content)
urlopen.validate()
dumps.validate()
开发者ID:viniciuschagas,项目名称:restfulie-python,代码行数:13,代码来源:entry_point_post_spec.py
示例8: it_should_allow_posting_as_xml
def it_should_allow_posting_as_xml(self):
uri = 'http://coolresource/post-here'
content = 'some content'
encoded_content = Dummy()
with Mock() as urlencode:
from urllib import urlencode
urlencode({'content': content}) >> encoded_content
with Mock() as urlopen:
from urllib2 import urlopen
urlopen(uri, encoded_content)
Restfulie.at(uri).as_('application/xml').post(content)
urlencode.validate()
urlopen.validate()
开发者ID:elesbom,项目名称:restfulie-python,代码行数:13,代码来源:entry_point_post_spec.py
示例9: test_extraction_with_parameter_metadata
def test_extraction_with_parameter_metadata(self):
pdf = open(join(FOLDER_PATH, 'teste.pdf')).read()
pdf64 = b64encode(pdf)
service = Restfulie.at("http://localhost:8887/").auth('test', 'test').as_('application/json')
response = service.post(file=pdf64, filename='test.pdf')
resource = response.resource()
resource.doc_key |should_not| equal_to(None)
sleep(5)
response = service.get(key=resource.doc_key, metadata=True).resource()
metadata_key = response.metadata_key
metadata_key |should_not| equal_to(None)
sam = Restfulie.at('http://0.0.0.0:8888/').auth('test', 'test').as_('application/json')
resource = sam.get(key=metadata_key).resource()
resource.data.autor |should| equal_to('Jose')
开发者ID:nsi-iff,项目名称:metadataservice_buildout,代码行数:16,代码来源:testMetadataService.py
示例10: test_restfulie_at
def test_restfulie_at():
"""
Running Restfulie.at("www.caelum.com.br") should return
a Request object with this URI
"""
assert Restfulie.at("www.caelum.com.br")
开发者ID:nsi-iff,项目名称:restfulie-py,代码行数:7,代码来源:restfulie_test.py
示例11: it_should_allow_posting_as_xml
def it_should_allow_posting_as_xml(self):
uri = "http://coolresource/post-here"
content = {"item": {"name": "something"}}
encoded_content = Dummy()
with Stub() as urlencode:
from urllib import urlencode
urlencode({"content": "<item><name>something</name></item>"}) >> encoded_content
with Stub() as response:
response.code >> 200
with Mock() as urlopen:
from urllib2 import urlopen
urlopen(uri, encoded_content) >> response
Restfulie.at(uri).as_("application/xml").post(content)
urlopen.validate()
开发者ID:raphaelcastro,项目名称:restfulie-python,代码行数:16,代码来源:entry_point_post_spec.py
示例12: run
def run(self, url, verb, video_uid):
try:
print "Sending callback to %s" % url
restfulie = Restfulie.at(url).as_('application/json')
response = getattr(restfulie, verb)(video_key=video_uid, done=False)
except Exception, e:
FailCallback.retry(exc=e, countdown=10)
开发者ID:nsi-iff,项目名称:nsi.videogranulate,代码行数:7,代码来源:tasks.py
示例13: run
def run(self, uid, callback_url, video_link, sam_settings):
self.callback_url = callback_url
self.sam = Restfulie.at(sam_settings['url']).auth(*sam_settings['auth']).as_('application/json')
self.destination_uid = uid
self.tmp_path = "/tmp/original-%s" % uuid4()
video_is_converted = False
if video_link:
self._download_video(video_link)
else:
response = self._get_from_sam(uid)
self._original_video = response.data.video
if not hasattr(response, 'converted'):
video_is_converted = False
else:
video_is_converted = response.data.converted
if not video_is_converted:
print "Conversion started."
self._process_video()
print "Conversion finished."
if not self.callback_url == None:
print "Callback task sent."
send_task('nsivideoconvert.tasks.Callback', args=(callback_url, self.destination_uid), queue='convert',
routing_key='convert')
else:
print "No callback."
return self.destination_uid
else:
raise VideoException("Video already converted.")
开发者ID:nsi-iff,项目名称:nsi.videoconvert,代码行数:30,代码来源:tasks.py
示例14: it_gets_raw_data_from_an_entry_point
def it_gets_raw_data_from_an_entry_point(self):
content = "<item><name>Rich Rock Sunshine</name></item>"
self.set_server_content(content)
resource = Restfulie.at(self.content_uri).raw().get()
resource.response.code |should| be(200)
resource.response.body |should| equal_to(content)
开发者ID:BecaMotta,项目名称:restfulie-python,代码行数:7,代码来源:entry_point_spec.py
示例15: run
def run(self, url, verb, doc_uid, **kwargs):
try:
print "Sending fail callback to %s" % url
restfulie = Restfulie.at(url).as_('application/json')
response = getattr(restfulie, verb.lower())(doc_key=doc_uid, done=False, error=True)
except Exception, e:
FailCallback.retry(exc=e, countdown=10)
开发者ID:nsi-iff,项目名称:nsi.cloudooomanager,代码行数:7,代码来源:tasks.py
示例16: it_retrieves_content_as_json
def it_retrieves_content_as_json(self):
content = '''{"item": {"name": "product", "price": 2}}'''
self.set_server_content(content, 'application/json')
resource = Restfulie.at(self.content_uri).get()
resource.item.name |should| equal_to('product')
resource.item.price |should| be(2)
开发者ID:BecaMotta,项目名称:restfulie-python,代码行数:7,代码来源:entry_point_spec.py
示例17: __init__
def __init__(self, *args, **kwargs):
FunkLoadTestCase.__init__(self, *args, **kwargs)
"""Setting up the benchmark cycle."""
self.server_url = self.conf_get('main', 'url')
self.sam = Restfulie.at('http://localhost:8888/').auth('test', 'test').as_('application/json')
self.lipsum = Lipsum()
self.uid_list = []
self.video_file = b64encode(open(join(FOLDER_PATH, 'input', 'rubik.flv')).read())
开发者ID:nsi-iff,项目名称:videoconvert_buildout,代码行数:8,代码来源:testFunkLoad.py
示例18: __init__
def __init__(self, *args, **kwargs):
FunkLoadTestCase.__init__(self, *args, **kwargs)
"""Setting up the benchmark cycle."""
self.server_url = self.conf_get("main", "url")
self.sam = Restfulie.at("http://localhost:8888/").auth("test", "test").as_("application/json")
self.uid_list = []
size_multiplier = int(self.conf_get("main", "request_size"))
self.data = b64encode("a" * 40 * 1024 * size_multiplier)
开发者ID:nsi-iff,项目名称:sam_buildout,代码行数:8,代码来源:testFunkLoad.py
示例19: clean_files
def clean_files(path, sam_host, sam_port, sam_user, sam_password):
print 'Cleaning the files...'
sam = Restfulie.at("http://%s:%s/" % (sam_host, sam_port))
sam = sam.auth(sam_user, sam_password).as_('application/json')
for entry in listdir(path):
if sam.get(key=entry).code == '404':
remove(join(path, entry))
print 'Done.'
开发者ID:nsi-iff,项目名称:nsi.sam,代码行数:8,代码来源:tasks.py
示例20: run
def run(self, url, verb, video_uid, grains_keys):
try:
print "Sending callback to %s" % url
restfulie = Restfulie.at(url).as_('application/json')
response = getattr(restfulie, verb)(video_key=video_uid, grains_keys=grains_keys, done=True)
except Exception, e:
print "Erro no callback."
Callback.retry(exc=e, countdown=10)
开发者ID:Dyogo,项目名称:nsi.videogranulate,代码行数:8,代码来源:tasks.py
注:本文中的restfulie.Restfulie类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论