コード例 #1
0
 def should_perform_assynchronous_requests(self):
     
     barrier = Semaphore(0)
     
     def callback(response):
         body = response.body
         try:
             assert "Response for" in body
             assert "/hello" in body
         finally:
             barrier.release()
     
     Restfulie.at("http://localhost:20144/hello").async(callback).get()
     
     barrier.acquire()
コード例 #2
0
 def should_perform_assynchronous_requests_with_arguments_to_the_callback_function(self):
     
     barrier = Semaphore(0)
     
     def callback(response, extra1, extra2):
         body = response.body
         try:
             assert "Response for" in body
             assert "/hello" in body
             assert extra1 == "first"
             assert extra2 == "second"
         finally:
             barrier.release()
     
     Restfulie.at("http://localhost:20144/hello").async(callback, args=("first", "second")).get()
     
     barrier.acquire()
コード例 #3
0
    def should_perform_async_requests_with_arguments_to_the_callback(self):
        barrier = Semaphore(0)

        def callback(response, extra1, extra2):
            body = response.body
            assert "Response for" in body
            assert "/hello" in body
            assert extra1 == "first"
            assert extra2 == "second"
            barrier.release()

        r = Restfulie.at("http://localhost:20144/hello")
        r = r. async (callback, args=("first", "second")).get()
        barrier.acquire()
        assert "Response for" in r.body
        assert "/hello" in r.body
コード例 #4
0
ファイル: restfulie_test.py プロジェクト: inean/restfulie-py
 def should_return_a_dsl_object(self):
     assert type(Restfulie.at("www.caelum.com.br")) == Configuration
コード例 #5
0
ファイル: client.py プロジェクト: inean/restfulie-py
from restfulie.restfulie import Restfulie
response = Restfulie.at("http://localhost:8080").accepts("application/json").get()
r = response.resource
print r.status
print r.servertime
print r.link('self')
a = response.links.follow().get()
for link in a.links:
    print link
print a


コード例 #6
0
 def should_perform_ordinary_requests(self):
     body = Restfulie.at("http://localhost:20144/hello").get().body
     assert "Response for" in body
     assert "/hello" in body
コード例 #7
0
 def should_perform_ordinary_requests_with_simple_auth(self):
     r = Restfulie.at("http://localhost:20144/auth").auth('test', 'test')
     response = r.get()
     body = response.body
     assert "worked" in body
コード例 #8
0
 def should_perform_requests_with_parameters_as_dict(self):
     d = {"action": "test"}
     response = Restfulie.at("http://localhost:20144").post(**d)
     print response.body
     body = response.body
     assert "This is a test" in body
コード例 #9
0
 def should_perform_requests_with_parameters_as_kwargs(self):
     response = Restfulie.at("http://localhost:20144").post(action="test")
     print response.body
     body = response.body
     assert "This is a test" in body
コード例 #10
0
ファイル: solver.py プロジェクト: inean/restfulie-py
from tornado.ioloop import IOLoop

found = False
visited = {}
steps = 0

def solve(current):
    global found
    global visited
    if not found and not current.link('exit'):
        directions = ["start", "east", "west", "south", "north"]
        for direction in directions:
            link = current.link(direction)
            if not found and link and not visited.get(link.href):
                visited[link.href] = True
                link.follow().get(callback=solve)

    else:
        IOLoop.instance().stop()
        print "FOUND!"
        found = True

# syncronous invoke
current = Restfulie.at('http://amundsen.com/examples/mazes/2d/five-by-five/').accepts("application/xml").get()

# async invoke
solve(current)

# start IOLoop
IOLoop.instance().start()
コード例 #11
0
    def should_perform_async_requests_without_callback(self):

        r = Restfulie.at("http://localhost:20144/hello").async().get()
        assert "Response for" in r.body
        assert "/hello" in r.body
コード例 #12
0
 def should_perform_ordinary_requests(self):
     body = Restfulie.at("http://localhost:20144/hello").get().body
     assert "Response for" in body
     assert "/hello" in body
コード例 #13
0
 def should_perform_ordinary_requests_with_simple_auth(self):
     r = Restfulie.at("http://localhost:20144/auth").auth('test', 'test')
     response = r.get()
     body = response.body
     assert "worked" in body
コード例 #14
0
 def should_perform_requests_with_parameters_as_dict(self):
     d = {"action": "test"}
     response = Restfulie.at("http://localhost:20144").post(**d)
     print response.body
     body = response.body
     assert "This is a test" in body
コード例 #15
0
 def should_perform_requests_with_parameters_as_kwargs(self):
     response = Restfulie.at("http://localhost:20144").post(action="test")
     print response.body
     body = response.body
     assert "This is a test" in body