def test_can_create_bindable_with_initial_uri_and_metadata(): uri = "http://localhost:7474/db/data/node/1" metadata = {"foo": "bar"} bindable = Service() bindable.bind(uri, metadata) assert bindable.bound assert bindable.uri == uri assert bindable.resource.metadata == metadata
def __init__(self, uri=None): if uri is None: service_root = ServiceRoot() manager = Resource(service_root.resource.metadata["management"]) monitor = Monitor(manager.metadata["services"]["monitor"]) uri = monitor.resource.uri Service.__init__(self) self.bind(uri)
def test_cannot_create_bindable_with_initial_uri_template_and_metadata(): uri = "http://localhost:7474/db/data/node/{node_id}" metadata = {"foo": "bar"} service = Service() try: service.bind(uri, metadata) except ValueError: assert True else: assert False
def __init__(self, content_type, uri, name=None): Service.__init__(self) self._content_type = content_type key_value_pos = uri.find("/{key}/{value}") if key_value_pos >= 0: self._searcher = ResourceTemplate(uri) self.bind(uri[:key_value_pos]) else: self.bind(uri) self._searcher = ResourceTemplate(uri.string + "/{key}/{value}") uri = self.resource.uri if self.graph.neo4j_version >= (1, 9): self._create_or_fail = Resource(uri.resolve("?uniqueness=create_or_fail")) self._get_or_create = Resource(uri.resolve("?uniqueness=get_or_create")) else: self._create_or_fail = None self._get_or_create = Resource(uri.resolve("?unique")) self._query_template = ResourceTemplate(uri.string + "{?query,order}") self._name = name or uri.path.segments[-1] self.__searcher_stem_cache = {}
def __init__(self, content_type, uri, name=None): Service.__init__(self) self._content_type = content_type key_value_pos = uri.find("/{key}/{value}") if key_value_pos >= 0: self._searcher = ResourceTemplate(uri) self.bind(uri[:key_value_pos]) else: self.bind(uri) self._searcher = ResourceTemplate(uri.string + "/{key}/{value}") uri = self.resource.uri if self.graph.neo4j_version >= (1, 9): self._create_or_fail = Resource( uri.resolve("?uniqueness=create_or_fail")) self._get_or_create = Resource( uri.resolve("?uniqueness=get_or_create")) else: self._create_or_fail = None self._get_or_create = Resource(uri.resolve("?unique")) self._query_template = ResourceTemplate(uri.string + "{?query,order}") self._name = name or uri.path.segments[-1] self.__searcher_stem_cache = {}
def test_can_create_bindable_with_initial_uri_template(): uri = "http://localhost:7474/db/data/node/{node_id}" bindable = Service() bindable.bind(uri) assert bindable.bound assert bindable.uri == uri