本文整理汇总了Python中restfulie.Restfulie类的典型用法代码示例。如果您正苦于以下问题:Python Restfulie类的具体用法?Python Restfulie怎么用?Python Restfulie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Restfulie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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")
示例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)
示例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)
示例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()
示例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)
示例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()
示例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()
示例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')
示例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")
示例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()
示例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)
示例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.")
示例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)
示例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)