def test_rest_client_with_redirect(self):
     rest_client = rest.Client()
     uri = "http://localhost:7474/db/data"
     rs = rest_client.send(rest.Request(None, "GET", uri))
     self.assertEqual(200, rs.status)
     self.assertEqual("http://localhost:7474/db/data/", rs.uri)
     self.assertTrue(rs.body)
 def test_rest_client_with_post(self):
     rest_client = rest.Client()
     uri = "http://localhost:7474/db/data/node"
     rs = rest_client.send(
         rest.Request(None, "POST", uri, {
             "name": "Alice",
         }))
     self.assertEqual(201, rs.status)
     self.assertEqual("http://localhost:7474/db/data/node", rs.uri)
     self.assertTrue(
         rs.location.startswith("http://localhost:7474/db/data/node/"))
     self.assertTrue(rs.body)
Exemple #3
0
 def _submit(self):
     """ Submits batch of requests, returning list of Response objects."""
     rs = self._graph_db._send(rest.Request(self._graph_db, "POST", self._graph_db._batch_uri, [
         request.description(id_)
         for id_, request in enumerate(self.requests)
     ], {'X-Stream': 'true'}))
     self.clear()
     return [
         rest.Response(
             self._graph_db,
             response.get("status", rs.status),
             response["from"],
             response.get("location", None),
             response.get("body", None),
             id=response.get("id", None),
         )
         for response in rs.body
     ]
 def test_rest_client_with_bad_port(self):
     rest_client = rest.Client()
     uri = "http://localhost:7575/db/data/"
     self.assertRaises(socket.error, rest_client.send,
                       rest.Request(None, "GET", uri))
 def test_rest_client_with_bad_path(self):
     rest_client = rest.Client()
     uri = "http://localhost:7474/foo/"
     self.assertRaises(rest.ResourceNotFound, rest_client.send,
                       rest.Request(None, "GET", uri))