コード例 #1
0
ファイル: relationship_test.py プロジェクト: zrg1993/py2neo
def test_relationship_exists_will_raise_non_404_errors(graph):
    with patch.object(_Resource, "get") as mocked:
        error = GraphError("bad stuff happened")
        error.response = DodgyClientError()
        mocked.side_effect = error
        a, b, ab = graph.create({}, {}, (0, "KNOWS", 1))
        try:
            _ = ab.exists
        except GraphError:
            assert True
        else:
            assert False
コード例 #2
0
ファイル: node_test.py プロジェクト: JohannesOos/py2neo
def test_node_exists_will_raise_non_404_errors():
    with patch.object(_Resource, "get") as mocked:
        error = GraphError("bad stuff happened")
        error.response = DodgyClientError()
        mocked.side_effect = error
        alice = Node(name="Alice Smith")
        alice.bind("http://localhost:7474/db/data/node/1")
        try:
            _ = alice.exists
        except GraphError:
            assert True
        else:
            assert False
コード例 #3
0
def test_node_exists_will_raise_non_404_errors():
    with patch.object(_Resource, "get") as mocked:
        error = GraphError("bad stuff happened")
        error.response = DodgyClientError()
        mocked.side_effect = error
        alice = Node(name="Alice Smith")
        alice.bind("http://localhost:7474/db/data/node/1")
        try:
            _ = alice.exists
        except GraphError:
            assert True
        else:
            assert False
コード例 #4
0
ファイル: schema.py プロジェクト: LiuYuQ/beifen
 def drop_index(self, label, property_key):
     """ Remove label index for a given property key.
     """
     try:
         self._index_key_template.expand(label=label, property_key=property_key).delete()
     except GraphError as error:
         cause = error.__cause__
         if isinstance(cause, Response):
             if cause.status_code == NOT_FOUND:
                 raise GraphError("No such schema index (label=%r, key=%r)" % (
                     label, property_key))
         raise
コード例 #5
0
ファイル: schema.py プロジェクト: LiuYuQ/beifen
 def drop_uniqueness_constraint(self, label, property_key):
     """ Remove the uniqueness constraint for a given property key.
     """
     try:
         self._uniqueness_constraint_key_template.expand(
             label=label, property_key=property_key).delete()
     except GraphError as error:
         cause = error.__cause__
         if isinstance(cause, Response):
             if cause.status_code == NOT_FOUND:
                 raise GraphError("No such unique constraint (label=%r, key=%r)" % (
                     label, property_key))
         raise