Exemplo n.º 1
0
 def makeresponse(*args, **kwargs):
     if len(returned) > len(responses):
         raise IndexError("Ran out of canned responses after %s calls" % len(returned))
     resp = Mock()
     resp.status_code = responses[len(returned)][0]
     responsefile = responses[len(returned)][1]
     if responsefile:
         responsefile = "test/files/triplestore/" + responsefile
         resp.content = util.readfile(responsefile, "rb")
         resp.text = util.readfile(responsefile)
         if responsefile.endswith(".json"):
             data = json.loads(util.readfile(responsefile))
             resp.json = Mock(return_value=data)
     returned.append(True)
     return resp
Exemplo n.º 2
0
 def makeresponse(*args, **kwargs):
     if len(returned) > len(responses):
         raise IndexError("Ran out of canned responses after %s calls" % len(returned))
     resp = Mock()
     resp.status_code = responses[len(returned)][0]
     responsefile = responses[len(returned)][1]
     if responsefile:
         responsefile = "test/files/triplestore/" + responsefile
         resp.content = util.readfile(responsefile, "rb")
         resp.text = util.readfile(responsefile)
         if responsefile.endswith(".json"):
             data = json.loads(util.readfile(responsefile))
             resp.json = Mock(return_value=data)
     returned.append(True)
     return resp