forked from ej2/python-quickbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
49 lines (34 loc) · 2.12 KB
/
test_utils.py
File metadata and controls
49 lines (34 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import unittest
from quickbooks import utils
class UtilsTests(unittest.TestCase):
def test_build_where_clause(self):
where_clause = utils.build_where_clause(field1=1,
field2="Someone's Company")
self.assertTrue("field1 = 1" in where_clause)
self.assertTrue("field2 = 'Someone\\\'s Company'" in where_clause)
def test_build_where_clause_unicode(self):
where_clause = utils.build_where_clause(field1=u"Test 1",
field2=u"Someone's Company")
self.assertTrue("field1 = 'Test 1'" in where_clause)
self.assertTrue("field2 = 'Someone\\\'s Company'" in where_clause)
def test_build_choose_clause_integers(self):
where_clause = utils.build_choose_clause(choices=[1, 2],
field="field1")
self.assertEqual(where_clause, "field1 in (1, 2)")
def test_build_choose_clause_strings(self):
where_clause = utils.build_choose_clause(choices=["val1", "val2"],
field="field1")
self.assertEqual(where_clause, "field1 in ('val1', 'val2')")
def test_build_choose_clause_quoted_value(self):
where_clause = utils.build_choose_clause(choices=["val1",
"Someone's Company"],
field="field1")
self.assertEqual(where_clause, "field1 in ('val1', 'Someone\\\'s Company')")
def test_build_choose_clause_unicode(self):
where_clause = utils.build_choose_clause(choices=[u"Test - & % $", u"Another Test"],
field="field1")
self.assertEqual(where_clause, "field1 in ('Test - & % $', 'Another Test')")
def test_build_choose_clause_unicode_escaped(self):
where_clause = utils.build_choose_clause(choices=[u"Test - & % $", u"Another's Test"],
field="field1")
self.assertEqual(where_clause, "field1 in ('Test - & % $', 'Another\\\'s Test')")