def connect(self, uri, user=None, password=None): if user: self.user = user else: user = self.user while True: graph_service = GraphService(uri, auth=(user, password)) uri = graph_service.address.uri["/"] try: _ = graph_service.kernel_version except Unauthorized: self.console.write() password = getpass("Enter password for user %s: " % user) except Forbidden: if graph_service.password_change_required(): new_password = getpass( "Password expired. Enter new password for user %s: " % user) password = graph_service.change_password(new_password) else: raise else: self.services[uri] = graph_service break self.graph_service = self.services[uri] self.run = self.graph_service.graph.run set_completer( SimpleCompleter(self.graph_service, cypher_keywords).complete)
def graph_service(uri): return GraphService(uri)
def test_graph_service_equality(graph_service): uri = graph_service.uri gs1 = GraphService(uri) gs2 = GraphService(uri) assert gs1 == gs2 assert hash(gs1) == hash(gs2)
def test_same_uri_gives_same_instance(graph_service): uri = graph_service.uri gs1 = GraphService(uri) gs2 = GraphService(uri) assert gs1 is gs2