13
13
14
14
from quickbooks .objects .base import PhoneNumber , QuickbooksBaseObject
15
15
from quickbooks .objects .department import Department
16
+ from quickbooks .objects .customer import Customer
16
17
from quickbooks .objects .journalentry import JournalEntry , JournalEntryLine
17
18
from quickbooks .objects .salesreceipt import SalesReceipt
18
19
from quickbooks .mixins import ObjectListMixin
@@ -157,7 +158,8 @@ def test_all_with_qb(self):
157
158
@patch ('quickbooks.mixins.ListMixin.where' )
158
159
def test_filter (self , where ):
159
160
Department .filter (max_results = 25 , start_position = '1' , Active = True )
160
- where .assert_called_once_with ("Active = True" , max_results = 25 , start_position = '1' , qb = None )
161
+ where .assert_called_once_with ("Active = True" , max_results = 25 , start_position = '1' ,
162
+ order_by = '' , qb = None )
161
163
162
164
def test_filter_with_qb (self ):
163
165
with patch .object (self .qb_client , 'query' ) as query :
@@ -166,13 +168,13 @@ def test_filter_with_qb(self):
166
168
167
169
@patch ('quickbooks.mixins.ListMixin.query' )
168
170
def test_where (self , query ):
169
- Department .where ("Active=True" , 1 , 10 )
171
+ Department .where ("Active=True" , start_position = 1 , max_results = 10 )
170
172
query .assert_called_once_with ("SELECT * FROM Department WHERE Active=True STARTPOSITION 1 MAXRESULTS 10" ,
171
173
qb = None )
172
174
173
175
def test_where_with_qb (self ):
174
176
with patch .object (self .qb_client , 'query' ) as query :
175
- Department .where ("Active=True" , 1 , 10 , qb = self .qb_client )
177
+ Department .where ("Active=True" , start_position = 1 , max_results = 10 , qb = self .qb_client )
176
178
self .assertTrue (query .called )
177
179
178
180
@patch ('quickbooks.mixins.QuickBooks.query' )
@@ -202,6 +204,16 @@ def test_count(self, query):
202
204
count = Department .count (where_clause = "Active=True" , qb = self .qb_client )
203
205
query .assert_called_once_with ("SELECT COUNT(*) FROM Department WHERE Active=True" )
204
206
207
+ @patch ('quickbooks.mixins.ListMixin.query' )
208
+ def test_order_by (self , query ):
209
+ Customer .filter (Active = True , order_by = 'DisplayName' )
210
+ query .assert_called_once_with ("SELECT * FROM Customer WHERE Active = True ORDERBY DisplayName" , qb = None )
211
+
212
+ def test_order_by_with_qb (self ):
213
+ with patch .object (self .qb_client , 'query' ) as query :
214
+ Customer .filter (Active = True , order_by = 'DisplayName' , qb = self .qb_client )
215
+ self .assertTrue (query .called )
216
+
205
217
206
218
class ReadMixinTest (unittest .TestCase ):
207
219
def setUp (self ):
0 commit comments