Exemplo n.º 1
0
 def syncAction(self, actions, verb, **params):
     expectedActionLink(actions, verb)
     ret = http.POST(self.opts, self.abs(actions.link[verb].href),
                     self.makeAction('false', '10', **params).dump(),
                     self.fmt.MEDIA_TYPE)
     expectedStatusCode(ret, 200)
     resp_action = self.fmt.parse(ret['body'])
     expectedActionStatus(resp_action.status, "COMPLETE")
Exemplo n.º 2
0
 def _init(self):
     response = http.POST(self.INIT)
     if response.status_code != http.codes.created:
         codename = http.status_codes.get(response.status_code)[0]
         raise exceptions.BadRequest('({0}) {1}'.format(response.status_code, codename))
     data = ElementTree.fromstring(response.text.encode('utf-8'))
     self.pin = data.find('code').text
     self.id = data.find('id').text
Exemplo n.º 3
0
    def asyncAction(self, actions, verb, **params):
        expectedActionLink(actions, verb)
        ret = http.POST(self.opts, self.abs(actions.link[verb].href),
                        self.makeAction('true', '5000', **params).dump(),
                        self.fmt.MEDIA_TYPE)
        expectedStatusCode(ret, 202)
        resp_action = self.fmt.parse(ret['body'])
        unexpectedActionStatus(resp_action.status, "COMPLETE")
        for i in range(1, 3):
            time.sleep(1)
            resp = http.GET(self.opts, self.abs(resp_action.href),
                            self.fmt.MEDIA_TYPE)
            expectedStatusCode(resp, 200)
            resp_action = self.fmt.parse(resp['body'])
            unexpectedActionStatus(resp_action.status, "COMPLETE")

        time.sleep(4)
        resp = http.GET(self.opts, self.abs(resp_action.href),
                        self.fmt.MEDIA_TYPE)
        expectedStatusCode(resp, 200)
        resp_action = self.fmt.parse(resp['body'])
        expectedActionStatus(resp_action.status, "COMPLETE")
Exemplo n.º 4
0
 def create(self, href, entity):
     ret = http.POST(self.opts, self.abs(href), entity.dump(),
                     self.fmt.MEDIA_TYPE)
     expectedStatusCode(ret, 201)
     return self.fmt.parse(ret['body'])