Ejemplo n.º 1
0
 def test_remote_rel_changes_can_be_pulled(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS")
     local.bind(self.graph, id=alice_bob._id)
     local.pull()
     assert local.type == alice_bob.type
     assert local.properties == alice_bob.properties
Ejemplo n.º 2
0
 def test_local_rel_changes_can_be_pushed(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS", since=1999)
     local.bind(self.graph, id=alice_bob._id)
     local.push()
     remote = Batch.single(self.graph, Batch.get_rel, local._id)
     assert remote.type == local.type
     assert remote.properties == local.properties
Ejemplo n.º 3
0
 def test_remote_rel_changes_can_be_pulled(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS")
     local.bind(self.graph, id=alice_bob._id)
     local.pull()
     assert local.type == alice_bob.type
     assert local.properties == alice_bob.properties
Ejemplo n.º 4
0
 def test_local_rel_changes_can_be_pushed(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS", since=1999)
     local.bind(self.graph, id=alice_bob._id)
     local.push()
     remote = Batch.single(self.graph, Batch.get_rel, local._id)
     assert remote.type == local.type
     assert remote.properties == local.properties
Ejemplo n.º 5
0
 def test_can_construct_rel_with_type_and_properties(self):
     rel = Rel("KNOWS", since=1999)
     assert rel.type == "KNOWS"
     assert rel.properties == {"since": 1999}
Ejemplo n.º 6
0
 def test_can_represent_rel_with_type(self):
     rel = Rel("KNOWS")
     string = repr(rel)
     assert string == '-[:KNOWS]->'
Ejemplo n.º 7
0
 def test_casting_string_and_dict_will_return_rel_with_properties(self):
     type = "KNOWS"
     properties = {"since": 1999}
     casted = Rel.cast((type, properties))
     assert casted == Rel(type, **properties)
Ejemplo n.º 8
0
 def test_can_construct_rel_with_type(self):
     rel = Rel("KNOWS")
     assert rel.type == "KNOWS"
     assert rel.properties == {}
Ejemplo n.º 9
0
 def test_casting_rel_will_return_same(self):
     rel = Rel("KNOWS", since=1999)
     casted = Rel.cast(rel)
     assert casted is rel
Ejemplo n.º 10
0
 def test_casting_string_will_return_rel_with_type(self):
     type = "KNOWS"
     casted = Rel.cast(type)
     assert casted == Rel(type)
Ejemplo n.º 11
0
 def test_unequal_rels(self):
     rel_1 = Rel("KNOWS", since=1999)
     rel_2 = Rel("KNOWS", since=2000)
     assert rel_1 != rel_2
Ejemplo n.º 12
0
 def test_casting_none_will_return_none(self):
     casted = Rel.cast(None)
     assert casted is None
Ejemplo n.º 13
0
 def test_can_represent_rel_with_type_and_properties(self):
     rel = Rel("KNOWS", since=1999)
     string = repr(rel)
     assert string == '-[:KNOWS {"since":1999}]->'
Ejemplo n.º 14
0
 def test_casting_rel_will_return_same(self):
     rel = Rel("KNOWS", since=1999)
     casted = Rel.cast(rel)
     assert casted is rel
Ejemplo n.º 15
0
 def test_can_hydrate_rel_with_type(self):
     hydrated = yaml.load('!Rel {"type":"KNOWS"}')
     assert hydrated == Rel("KNOWS")
     assert not hydrated.bound
Ejemplo n.º 16
0
 def test_casting_string_and_dict_will_return_rel_with_properties(self):
     type = "KNOWS"
     properties = {"since": 1999}
     casted = Rel.cast((type, properties))
     assert casted == Rel(type, **properties)
Ejemplo n.º 17
0
 def test_casting_string_will_return_rel_with_type(self):
     type = "KNOWS"
     casted = Rel.cast(type)
     assert casted == Rel(type)
Ejemplo n.º 18
0
 def test_equal_rels(self):
     rel_1 = Rel("KNOWS", since=1999)
     rel_2 = Rel("KNOWS", since=1999)
     assert rel_1 == rel_2
Ejemplo n.º 19
0
 def test_can_hydrate_rel_with_type_and_properties(self):
     hydrated = yaml.load(
         '!Rel {"type":"KNOWS","properties":{"since":1999}}')
     assert hydrated == Rel("KNOWS", since=1999)
     assert not hydrated.bound
Ejemplo n.º 20
0
 def test_rel_type(self):
     rel = Rel("KNOWS")
     assert rel.type == "KNOWS"
Ejemplo n.º 21
0
 def test_casting_none_will_return_none(self):
     casted = Rel.cast(None)
     assert casted is None