Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Jun 10, 2024
1 parent a79b867 commit 1ee2b53
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/query/test_querystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def test_add(self):
("SELECT price + $1", [1]),
)

def test_multiply(self):
query = QueryString("SELECT price") * 2
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price * $1", [2]),
)

def test_divide(self):
query = QueryString("SELECT price") / 1
self.assertIsInstance(query, QueryString)
Expand Down Expand Up @@ -92,3 +100,67 @@ def test_ilike(self):
query.compile_string(),
("strip(name) ILIKE $1", ["Python%"]),
)

def test_greater_than(self):
query = QueryString("SELECT price") > 10
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price > $1", [10]),
)

def test_greater_equal_than(self):
query = QueryString("SELECT price") >= 10
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price >= $1", [10]),
)

def test_less_than(self):
query = QueryString("SELECT price") < 10
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price < $1", [10]),
)

def test_less_equal_than(self):
query = QueryString("SELECT price") <= 10
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price <= $1", [10]),
)

def test_equals(self):
query = QueryString("SELECT price") == 10
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price = $1", [10]),
)

def test_not_equals(self):
query = QueryString("SELECT price") != 10
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price != $1", [10]),
)

def test_is_in(self):
query = QueryString("SELECT price").is_in([10, 20, 30])
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price IN $1", [[10, 20, 30]]),
)

def test_not_in(self):
query = QueryString("SELECT price").not_in([10, 20, 30])
self.assertIsInstance(query, QueryString)
self.assertEqual(
query.compile_string(),
("SELECT price NOT IN $1", [[10, 20, 30]]),
)

0 comments on commit 1ee2b53

Please sign in to comment.