Ejemplo n.º 1
0
def test_cannot_write_none_identifier():
    r = Representation()
    try:
        r.write_identifier(None)
    except ValueError:
        assert True
    else:
        assert False
Ejemplo n.º 2
0
def test_can_write_relationship_with_properties():
    r = Representation()
    r.write(
        Relationship({"name": "Fred"}, ("LIVES WITH", {
            "place": "Bedrock"
        }), {"name": "Wilma"}))
    written = repr(r)
    assert written == '({name:"Fred"})-[:`LIVES WITH` {place:"Bedrock"}]->({name:"Wilma"})'
Ejemplo n.º 3
0
def test_cannot_write_none_identifier():
    r = Representation()
    try:
        r.write_identifier(None)
    except ValueError:
        assert True
    else:
        assert False
Ejemplo n.º 4
0
def test_can_write_array():
    r = Representation()
    r.write([1, 1, 2, 3, 5, 8, 13])
    written = repr(r)
    assert written == "[1,1,2,3,5,8,13]"
Ejemplo n.º 5
0
def test_can_write_simple_path():
    r = Representation()
    r.write(Path({}, "LOVES", {}, Rev("HATES"), {}, "KNOWS", {}))
    written = repr(r)
    assert written == "()-[:LOVES]->()<-[:HATES]-()-[:KNOWS]->()"
Ejemplo n.º 6
0
def test_can_write_simple_path():
    r = Representation()
    r.write(Path({}, "LOVES", {}, Rev("HATES"), {}, "KNOWS", {}))
    written = repr(r)
    assert written == "()-[:LOVES]->()<-[:HATES]-()-[:KNOWS]->()"
Ejemplo n.º 7
0
def test_can_write_simple_relationship():
    r = Representation()
    r.write(Relationship({}, "KNOWS", {}))
    written = repr(r)
    assert written == "()-[:KNOWS]->()"
Ejemplo n.º 8
0
def test_can_write_mapping():
    r = Representation()
    r.write({"one": "eins", "two": "zwei", "three": "drei"})
    written = repr(r)
    assert written == '{one:"eins",three:"drei",two:"zwei"}'
Ejemplo n.º 9
0
def test_can_write_identifier_containing_back_ticks():
    r = Representation()
    r.write_identifier("foo `bar`")
    written = repr(r)
    assert written == "`foo ``bar```"
Ejemplo n.º 10
0
def test_can_write_simple_identifier():
    r = Representation()
    r.write_identifier("foo")
    written = repr(r)
    assert written == "foo"
Ejemplo n.º 11
0
def test_can_write_node_with_labels():
    r = Representation()
    r.write(Node("Dark Brown", "Chicken"))
    written = repr(r)
    assert written == '(:Chicken:`Dark Brown`)'
Ejemplo n.º 12
0
def test_can_write_simple_node():
    r = Representation()
    r.write(Node())
    written = repr(r)
    assert written == "()"
Ejemplo n.º 13
0
def test_can_write_identifier_containing_back_ticks():
    r = Representation()
    r.write_identifier("foo `bar`")
    written = repr(r)
    assert written == "`foo ``bar```"
Ejemplo n.º 14
0
def test_can_write_identifier_with_odd_chars():
    r = Representation()
    r.write_identifier("foo bar")
    written = repr(r)
    assert written == "`foo bar`"
Ejemplo n.º 15
0
def test_can_write_simple_identifier():
    r = Representation()
    r.write_identifier("foo")
    written = repr(r)
    assert written == "foo"
Ejemplo n.º 16
0
def test_writing_none_writes_nothing():
    r = Representation()
    r.write(None)
    written = repr(r)
    assert written == ""
Ejemplo n.º 17
0
def test_can_write_mapping():
    r = Representation()
    r.write({"one": "eins", "two": "zwei", "three": "drei"})
    written = repr(r)
    assert written == '{one:"eins",three:"drei",two:"zwei"}'
Ejemplo n.º 18
0
def test_can_write_node_with_properties():
    r = Representation()
    r.write(Node(name="Gertrude", age=3))
    written = repr(r)
    assert written == '({age:3,name:"Gertrude"})'
Ejemplo n.º 19
0
def test_writing_none_writes_nothing():
    r = Representation()
    r.write(None)
    written = repr(r)
    assert written == ""
Ejemplo n.º 20
0
def test_can_write_simple_node():
    r = Representation()
    r.write(Node())
    written = repr(r)
    assert written == "()"
Ejemplo n.º 21
0
def test_can_write_identifier_with_odd_chars():
    r = Representation()
    r.write_identifier("foo bar")
    written = repr(r)
    assert written == "`foo bar`"
Ejemplo n.º 22
0
def test_can_write_node_with_properties():
    r = Representation()
    r.write(Node(name="Gertrude", age=3))
    written = repr(r)
    assert written == '({age:3,name:"Gertrude"})'
Ejemplo n.º 23
0
def test_can_write_node_with_labels_and_properties():
    r = Representation()
    r.write(Node("Dark Brown", "Chicken", name="Gertrude", age=3))
    written = repr(r)
    assert written == '(:Chicken:`Dark Brown` {age:3,name:"Gertrude"})'
Ejemplo n.º 24
0
def test_can_write_array():
    r = Representation()
    r.write([1, 1, 2, 3, 5, 8, 13])
    written = repr(r)
    assert written == "[1,1,2,3,5,8,13]"
Ejemplo n.º 25
0
def test_can_write_node_with_labels():
    r = Representation()
    r.write(Node("Dark Brown", "Chicken"))
    written = repr(r)
    assert written == '(:Chicken:`Dark Brown`)'
Ejemplo n.º 26
0
def test_can_write_simple_relationship():
    r = Representation()
    r.write(Relationship({}, "KNOWS", {}))
    written = repr(r)
    assert written == "()-[:KNOWS]->()"
Ejemplo n.º 27
0
def test_can_write_node_with_labels_and_properties():
    r = Representation()
    r.write(Node("Dark Brown", "Chicken", name="Gertrude", age=3))
    written = repr(r)
    assert written == '(:Chicken:`Dark Brown` {age:3,name:"Gertrude"})'
Ejemplo n.º 28
0
def test_can_write_relationship_with_properties():
    r = Representation()
    r.write(Relationship(
        {"name": "Fred"}, ("LIVES WITH", {"place": "Bedrock"}), {"name": "Wilma"}))
    written = repr(r)
    assert written == '({name:"Fred"})-[:`LIVES WITH` {place:"Bedrock"}]->({name:"Wilma"})'
Ejemplo n.º 29
0
def test_can_write_simple_rev():
    r = Representation()
    r.write(Rev("KNOWS"))
    written = repr(r)
    assert written == "<-[:KNOWS]-"
Ejemplo n.º 30
0
def test_can_write_simple_rev():
    r = Representation()
    r.write(Rev("KNOWS"))
    written = repr(r)
    assert written == "<-[:KNOWS]-"