Example #1
0
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
Example #2
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
Example #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
Example #4
0
 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
Example #5
0
 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