Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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}
Esempio n. 6
0
 def test_can_represent_rel_with_type(self):
     rel = Rel("KNOWS")
     string = repr(rel)
     assert string == '-[:KNOWS]->'
Esempio 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)
Esempio n. 8
0
 def test_can_construct_rel_with_type(self):
     rel = Rel("KNOWS")
     assert rel.type == "KNOWS"
     assert rel.properties == {}
Esempio n. 9
0
 def test_casting_rel_will_return_same(self):
     rel = Rel("KNOWS", since=1999)
     casted = Rel.cast(rel)
     assert casted is rel
Esempio n. 10
0
 def test_casting_string_will_return_rel_with_type(self):
     type = "KNOWS"
     casted = Rel.cast(type)
     assert casted == Rel(type)
Esempio 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
Esempio n. 12
0
 def test_casting_none_will_return_none(self):
     casted = Rel.cast(None)
     assert casted is None
Esempio 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}]->'
Esempio n. 14
0
 def test_casting_rel_will_return_same(self):
     rel = Rel("KNOWS", since=1999)
     casted = Rel.cast(rel)
     assert casted is rel
Esempio 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
Esempio 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)
Esempio n. 17
0
 def test_casting_string_will_return_rel_with_type(self):
     type = "KNOWS"
     casted = Rel.cast(type)
     assert casted == Rel(type)
Esempio 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
Esempio 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
Esempio n. 20
0
 def test_rel_type(self):
     rel = Rel("KNOWS")
     assert rel.type == "KNOWS"
Esempio n. 21
0
 def test_casting_none_will_return_none(self):
     casted = Rel.cast(None)
     assert casted is None