Skip to content

Commit

Permalink
Adding tests for Issue #6
Browse files Browse the repository at this point in the history
Respect parameter formatting style in inclause filter
  • Loading branch information
sripathikrishnan committed Nov 21, 2016
1 parent 0889ab4 commit 46dd8d4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion jinjasql/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
from ordereddict import OrderedDict

from threading import local
import random
from random import Random

_thread_local = local()

# This is mocked in unit tests for deterministic behaviour
random = Random()


class JinjaSqlException(Exception):
pass

Expand Down
4 changes: 3 additions & 1 deletion run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import unittest
from tests import all_tests
import sys

if __name__ == "__main__":
tests = all_tests()
results = unittest.TextTestRunner().run(tests)
ret = not unittest.TextTestRunner().run(tests).wasSuccessful()
sys.exit(ret)
15 changes: 13 additions & 2 deletions tests/yaml/macros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ template: >
SELECT project, timesheet, hours
FROM timesheet
WHERE project_id = {{request.project_id}}
and user_id = {{ session.user_id }}
and user_id = {{ session.user_id }}
expected_sql:
format: >
SELECT project, timesheet, hours
Expand Down Expand Up @@ -35,7 +35,18 @@ expected_sql:
format: >
select * from timesheet
where day in (%s,%s,%s,%s,%s)
qmark: >
select * from timesheet
where day in (?,?,?,?,?)
numeric: >
select * from timesheet
where day in (:1,:2,:3,:4,:5)
numeric: >
select * from timesheet
where day in (:1,:2,:3,:4,:5)
numeric: >
select * from timesheet
where day in (:1,:2,:3,:4,:5)
---
name: test_macros
template: >
Expand Down

0 comments on commit 46dd8d4

Please sign in to comment.