Exemplo n.º 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")])]
     }
Exemplo n.º 2
0
 def test_order_by_no_arg():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind ORDER BY")
Exemplo n.º 3
0
 def test_constructor_bad_query():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("BAD, BAD QUERY")
Exemplo n.º 4
0
 def test_false():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=FALSE")
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(False)])]
     }
Exemplo n.º 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)])]
     }
Exemplo n.º 6
0
 def test_is_no_ancestor():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE prop1 IS 'OtherKind'")
Exemplo n.º 7
0
 def test_null():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=NULL")
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(None)])]
     }
Exemplo n.º 8
0
 def test_orderings():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.orderings() == [("prop4", 1), ("prop1", 2)]
Exemplo n.º 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
Exemplo n.º 10
0
 def test_constructor_reserved_where_identifier():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE WHERE")
Exemplo n.º 11
0
 def test_constructor_empty_where_condition_value():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=")
Exemplo n.º 12
0
 def test_constructor_bad_where_condition():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE WE_ARE")
Exemplo n.º 13
0
 def test_constructor_extra_query():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind; END")
Exemplo n.º 14
0
 def test_constructor_incomplete_query():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT")
Exemplo n.º 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'"))
Exemplo n.º 16
0
 def test_projection():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.projection() == ("prop1", "prop2")
Exemplo n.º 17
0
 def test_ancestor_no_is():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE ANCESTOR='OtherKind'")
Exemplo n.º 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
Exemplo n.º 19
0
 def test_func():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=key(:1)")
     assert gql.filters() == {("prop1", "="): [("key", [1])]}
Exemplo n.º 20
0
 def test_kind():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.kind() == "SomeKind"
     assert gql._entity == "SomeKind"
Exemplo n.º 21
0
 def test_true():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=TRUE")
     assert gql.filters() == {
         ("prop1", "="): [("nop", [gql_module.Literal(True)])]
     }
Exemplo n.º 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")])]
     }
Exemplo n.º 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)])]
     }
Exemplo n.º 24
0
 def test_cast_list_no_in():
     with pytest.raises(exceptions.BadQueryError):
         gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=(1, 2, 3)")
Exemplo n.º 25
0
 def test_order_by_ascending():
     gql = gql_module.GQL("SELECT * FROM SomeKind ORDER BY prop1 ASC")
     assert gql.orderings() == [("prop1", 1)]
Exemplo n.º 26
0
 def test_reference():
     gql = gql_module.GQL("SELECT * FROM SomeKind WHERE prop1=:ref")
     assert gql.filters() == {("prop1", "="): [("nop", ["ref"])]}
Exemplo n.º 27
0
 def test_constructor():
     gql = gql_module.GQL(GQL_QUERY)
     assert gql.kind() == "SomeKind"
Exemplo n.º 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)])]
     }