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)
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))