def test_build_set_prepared(): gen = build_set( OrderedDict([ ('custom_param', param('myparam')), ('auto_param', autoparam), ])) eq_(gen, '"custom_param"=%(myparam)s, "auto_param"=%(auto_param)s')
def test_select_param(): gen = select('table', OrderedDict([ ('custom_param', param('my_param')), ('auto_param', autoparam), ('using_alias', ___), ])) exp = ( 'SELECT * FROM "table" WHERE "custom_param" = %(my_param)s ' 'AND "auto_param" = %(auto_param)s AND "using_alias" = %(using_alias)s' ) eq_(gen, exp)
def test_build_where_prepared(): gen = build_where( OrderedDict([ ('custom_param', param('my_param')), ('auto_param', autoparam), ('using_alias', ___), ])) exp = ('"custom_param" = %(my_param)s AND "auto_param" = %(auto_param)s ' 'AND "using_alias" = %(using_alias)s') eq_(gen, exp)
def test_param_query(self): with self.db as cur: cur.execute( select( 'person', {'person_id': param('person_id')} ), {'person_id': 'mosky'} ) self.db._conn.rollback()
def test_select_param(): gen = select( 'table', OrderedDict([ ('custom_param', param('my_param')), ('auto_param', autoparam), ('using_alias', ___), ])) exp = ( 'SELECT * FROM "table" WHERE "custom_param" = %(my_param)s ' 'AND "auto_param" = %(auto_param)s AND "using_alias" = %(using_alias)s' ) eq_(gen, exp)
def test_param_query(self): with self.db as cur: cur.execute(select("person", {"person_id": param("person_id")}), {"person_id": "mosky"}) self.db._conn.rollback()
def test_param_repr(): eq_(repr(param('Mosky')), "param('Mosky')")
def test_build_set_prepared(): gen = build_set(OrderedDict([("custom_param", param("myparam")), ("auto_param", autoparam)])) eq_(gen, '"custom_param"=%(myparam)s, "auto_param"=%(auto_param)s')
def test_build_where_prepared(): gen = build_where( OrderedDict([("custom_param", param("my_param")), ("auto_param", autoparam), ("using_alias", ___)]) ) exp = '"custom_param" = %(my_param)s AND "auto_param" = %(auto_param)s ' 'AND "using_alias" = %(using_alias)s' eq_(gen, exp)
def test_param_query(self): with self.db as cur: cur.execute(select('person', {'person_id': param('person_id')}), {'person_id': 'mosky'}) self.db._conn.rollback()