Пример #1
0
 def test_discarding_non_existent_label_is_ignored(self):
     node = Node("Person", name="Alice")
     node.discard_label("Employee")
     assert node.labels() == {"Person"}
Пример #2
0
 def test_can_clear_labels(self):
     node = Node("Person", "Employee", name="Alice")
     node.clear_labels()
     assert node.labels() == set()
Пример #3
0
 def test_removing_non_existent_label_fails(self):
     node = Node("Person", name="Alice")
     with self.assertRaises(KeyError):
         node.remove_label("Employee")
Пример #4
0
 def test_can_discard_label(self):
     node = Node("Person", "Employee", name="Alice")
     node.discard_label("Employee")
     assert node.labels() == {"Person"}
Пример #5
0
 def test_update_labels(self):
     node = Node("Person", name="Alice")
     node.update_labels({"Person", "Employee"})
     assert node.labels() == {"Person", "Employee"}
Пример #6
0
 def test_add_label_is_idempotent(self):
     node = Node("Person", name="Alice")
     node.add_label("Employee")
     node.add_label("Employee")
     assert node.labels() == {"Person", "Employee"}
Пример #7
0
 def test_can_clear_labels(self):
     node = Node("Person", "Employee", name="Alice")
     node.clear_labels()
     assert node.labels() == set()
Пример #8
0
 def test_equality(self):
     other_node = Node("Person", "Employee", name="Alice", age=33)
     assert alice == other_node
Пример #9
0
 def test_can_discard_label(self):
     node = Node("Person", "Employee", name="Alice")
     node.discard_label("Employee")
     assert node.labels() == {"Person"}
Пример #10
0
 def test_discarding_non_existent_label_is_ignored(self):
     node = Node("Person", name="Alice")
     node.discard_label("Employee")
     assert node.labels() == {"Person"}
Пример #11
0
 def test_removing_non_existent_label_fails(self):
     node = Node("Person", name="Alice")
     with self.assertRaises(KeyError):
         node.remove_label("Employee")
Пример #12
0
 def test_add_label_is_idempotent(self):
     node = Node("Person", name="Alice")
     node.add_label("Employee")
     node.add_label("Employee")
     assert node.labels() == {"Person", "Employee"}
Пример #13
0
 def test_inequality(self):
     other_node = Node("Person", "Employee", name="Bob", age=44)
     assert alice != other_node
Пример #14
0
 def test_has_label(self):
     node = Node("Person", name="Alice")
     assert node.has_label("Person")
     assert not node.has_label("Employee")
Пример #15
0
 def test_has_label(self):
     node = Node("Person", name="Alice")
     assert node.has_label("Person")
     assert not node.has_label("Employee")
Пример #16
0
 def test_update_labels(self):
     node = Node("Person", name="Alice")
     node.update_labels({"Person", "Employee"})
     assert node.labels() == {"Person", "Employee"}
Пример #17
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from unittest import TestCase

from cypy.primitive import PropertySet, PropertyContainer, TraversableGraph, \
    Graph, Node, Relationship, Path, Record, RecordList

alice = Node("Person", "Employee", name="Alice", age=33)
bob = Node("Person")
carol = Node("Person")
dave = Node("Person")

alice_knows_bob = Relationship(alice, "KNOWS", bob, since=1999)
alice_likes_carol = Relationship(alice, "LIKES", carol)
carol_dislikes_bob = Relationship(carol, "DISLIKES", bob)
carol_married_to_dave = Relationship(carol, "MARRIED_TO", dave)
dave_works_for_dave = Relationship(dave, "WORKS_FOR", dave)

record_keys = ["employee_id", "Person"]
record_a = Record(record_keys, [1001, alice])
record_b = Record(record_keys, [1002, bob])
record_c = Record(record_keys, [1003, carol])
record_d = Record(record_keys, [1004, dave])