Beispiel #1
0
 def test_ancestor_is():
     gql = gql_module.GQL(
         "SELECT * FROM SomeKind WHERE ANCESTOR IS 'AnyKind'")
     assert gql.filters() == {
         (-1, "is"): [("nop", [gql_module.Literal("AnyKind")])]
     }
Beispiel #2
0
 def test_order_by_no_arg():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind ORDER BY")
 def test_constructor_bad_query():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("BAD, BAD QUERY")
Beispiel #4
0
 def test_false():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=FALSE")
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(False)])]
     }
Beispiel #5
0
 def test_quoted_identifier():
     gql = gql_module.GQL('SELECT * FROM SomeKind WHERE "prop1"=3.14')
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(3.14)])]
     }
Beispiel #6
0
 def test_is_no_ancestor():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE prop1 IS 'OtherKind'")
Beispiel #7
0
 def test_null():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=NULL")
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(None)])]
     }
Beispiel #8
0
 def test_orderings():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.orderings() == [("prop4", 1), ("prop1", 2)]
Beispiel #9
0
 def test_is_keys_only():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.is_keys_only() is False
     gql = gql_module.GQL("SELECT __key__ from SomeKind")
     assert gql.is_keys_only() is True
 def test_constructor_reserved_where_identifier():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE WHERE")
 def test_constructor_empty_where_condition_value():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=")
 def test_constructor_bad_where_condition():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE WE_ARE")
 def test_constructor_extra_query():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind; END")
 def test_constructor_incomplete_query():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT")
Beispiel #15
0
 def test_ancestor_multiple_ancestors():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL(
             ("SELECT * FROM SomeKind WHERE ANCESTOR IS 'AnyKind' AND "
              "ANCESTOR IS 'OtherKind'"))
Beispiel #16
0
 def test_projection():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.projection() == ("prop1", "prop2")
Beispiel #17
0
 def test_ancestor_no_is():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE ANCESTOR='OtherKind'")
Beispiel #18
0
 def test_is_distinct():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.is_distinct() is False
     gql = gql_module.GQL("SELECT DISTINCT prop1 from SomeKind")
     assert gql.is_distinct() is True
Beispiel #19
0
 def test_func():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=key(:1)")
     assert gql.filters() == {("prop1", "="): [("key", [1])]}
Beispiel #20
0
 def test_kind():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.kind() == "SomeKind"
     assert gql._entity == "SomeKind"
Beispiel #21
0
 def test_true():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=TRUE")
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(True)])]
     }
Beispiel #22
0
 def test_cast():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=user('js')")
     assert gql.filters() == {
         ("prop1", "="): [("user", [gql_module.Literal("js")])]
     }
Beispiel #23
0
 def test_float():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=3.14")
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(3.14)])]
     }
Beispiel #24
0
 def test_cast_list_no_in():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=(1, 2, 3)")
Beispiel #25
0
 def test_order_by_ascending():
     gql = gql_module.GQL("SELECT * FROM SomeKind ORDER BY prop1 ASC")
     assert gql.orderings() == [("prop1", 1)]
Beispiel #26
0
 def test_reference():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=:ref")
     assert gql.filters() == {("prop1", "="): [("nop", ["ref"])]}
Beispiel #27
0
 def test_constructor():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.kind() == "SomeKind"
Beispiel #28
0
 def test_in_list():
     Literal = gql_module.Literal
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1 IN (1, 2, 3)")
     assert gql.filters() == {
         ("prop1", "IN"): [("list", [Literal(1), Literal(2), Literal(3)])]
     }