コード例 #1
0
ファイル: bind_unbind_test.py プロジェクト: zrg1993/py2neo
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
コード例 #2
0
ファイル: __init__.py プロジェクト: JohannesOos/py2neo
 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)
コード例 #3
0
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
コード例 #4
0
ファイル: __init__.py プロジェクト: zrg1993/py2neo
 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)
コード例 #5
0
ファイル: bind_unbind_test.py プロジェクト: zrg1993/py2neo
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
コード例 #6
0
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
コード例 #7
0
ファイル: index.py プロジェクト: Sapphirine/stackexchange
 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 = {}
コード例 #8
0
 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 = {}
コード例 #9
0
ファイル: bind_unbind_test.py プロジェクト: zrg1993/py2neo
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
コード例 #10
0
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