Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_query_filename_relative(self):
User.insert(values={'name': 'jardin'})
df = jardin.query(
filename='tests/support/select_users.sql',
db='jardin_test'
)
self.assertEqual(len(df), 1)
self.assertEqual(df.name.iloc[0], 'jardin')
def test_query_filename_absolute(self):
User.insert(values={'name': 'jardin'})
filename = os.path.join(os.environ['PWD'], 'tests/support/select_users.sql')
df = jardin.query(
filename=filename,
db='jardin_test'
)
self.assertEqual(len(df), 1)
self.assertEqual(df.name.iloc[0], 'jardin')
def test_query_sql(self):
User.insert(values={'name': 'jardin'})
df = jardin.query(
sql='SELECT * FROM users;',
db='jardin_test'
)
self.assertEqual(len(df), 1)
self.assertEqual(df.name.iloc[0], 'jardin')
def test_query_params(self):
if User.db().db_config.scheme == 'sqlite':
return
User.insert(values={'name': 'jardin'})
df = jardin.query(
sql='SELECT * FROM users WHERE name IN %(names)s;',
params={'names': ['jardin']},
db='jardin_test'
)
self.assertEqual(len(df), 1)