|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- encoding: utf-8 -*- |
| 3 | + |
| 4 | +# Copyright (c) 2002-2016 "Neo Technology," |
| 5 | +# Network Engine for Objects in Lund AB [http://neotechnology.com] |
| 6 | +# |
| 7 | +# This file is part of Neo4j. |
| 8 | +# |
| 9 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | +# you may not use this file except in compliance with the License. |
| 11 | +# You may obtain a copy of the License at |
| 12 | +# |
| 13 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | +# |
| 15 | +# Unless required by applicable law or agreed to in writing, software |
| 16 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | +# See the License for the specific language governing permissions and |
| 19 | +# limitations under the License. |
| 20 | + |
| 21 | + |
| 22 | +from neo4j.v1 import GraphDatabase, basic_auth, ProtocolError |
| 23 | + |
| 24 | +from test.util import ServerTestCase, restart_server |
| 25 | + |
| 26 | + |
| 27 | +auth_token = basic_auth("neo4j", "password") |
| 28 | + |
| 29 | + |
| 30 | +class ServerRestartTestCase(ServerTestCase): |
| 31 | + |
| 32 | + def test_server_shutdown_detection(self): |
| 33 | + driver = GraphDatabase.driver("bolt://localhost", auth=auth_token) |
| 34 | + session = driver.session() |
| 35 | + session.run("RETURN 1").consume() |
| 36 | + assert restart_server() |
| 37 | + with self.assertRaises(ProtocolError): |
| 38 | + session.run("RETURN 1").consume() |
| 39 | + session.close() |
0 commit comments