def default_select() -> que.Select: field = que.Field("foo", "bar") fylter = que.Filter(field) select = que.Select(table="foo", schema="bar", fields=[field], filters=[fylter]) return select
def default_update() -> que.Update: field = que.Field("foo", "bar") fylter = que.Filter(field) update = que.Update(table="foo", schema="bar", fields=[field], filters=[fylter]) return update
def test_filter_invalid(): with pytest.raises(TypeError): que.Filter(que.Field("foo"))
def test_field_invalid(): with pytest.raises(TypeError): que.Field()
def default_delete() -> que.Delete: field = que.Field("foo", "bar") fylter = que.Filter(field) delete = que.Delete(table="foo", schema="bar", filters=[fylter]) return delete
def default_field_list() -> que.FieldList: return que.FieldList([que.Field("foo", "bar")])
def test_append_filterlist(): fylter = que.Filter(que.Field("foo", "bar")) lyst = que.FilterList() lyst.append(fylter) assert fylter in lyst
def test_write_invalid(): with pytest.raises(TypeError): que.Insert("foo", fields=[que.Field(value="foo")])
def default_insert() -> que.Insert: field = que.Field("foo", "bar") insert = que.Insert(table="foo", schema="bar", fields=[field]) return insert
def test_insert_get_returning(default_insert): default_insert.returns = que.Field("id") sql, args = default_insert.to_sql() assert sql.endswith("RETURNING id")
def test_update_get_returning(default_update): default_update.returns = que.Field("id") sql, args = default_update.to_sql() assert sql.endswith("RETURNING id")