@@ -46,6 +46,12 @@ def check_positive_number(self, f):
4646 for bad in ('1.2' , '1' , - 1 , - 1.1 , 0 ):
4747 self .check_invalid_transaction (f (bad ))
4848
49+ def check_bool (self , object , key ):
50+ for good in (True , False ):
51+ self .check_transaction ({object : {key : good }})
52+ for bad in ('' , 0 , 'True' ):
53+ self .check_invalid_transaction ({object : {key : bad }})
54+
4955
5056class TestAccount (unittest .TestCase , ValidationBase ):
5157 def test_account_user_id (self ):
@@ -160,7 +166,7 @@ def test_missing_device(self):
160166 def test_user_agent (self ):
161167 self .check_str_type ('device' , 'user_agent' )
162168
163- def test_user_agent (self ):
169+ def test_accept_language (self ):
164170 self .check_str_type ('device' , 'accept_language' )
165171
166172
@@ -219,6 +225,12 @@ def test_affiliate_id(self):
219225 def test_subaffiliate_id (self ):
220226 self .check_str_type ('order' , 'subaffiliate_id' )
221227
228+ def test_is_gift (self ):
229+ self .check_bool ('order' , 'is_gift' )
230+
231+ def test_has_gift_message (self ):
232+ self .check_bool ('order' , 'has_gift_message' )
233+
222234 def test_referrer_uri (self ):
223235 for good in ('http://www.mm.com/fadsf' , 'https://x.org/' ):
224236 self .check_transaction ({'order' : {'referrer_uri' : good }})
@@ -234,11 +246,7 @@ def test_processor(self):
234246 self .check_invalid_transaction ({'payment' : {'processor' : bad }})
235247
236248 def test_was_authorized (self ):
237- for good in (True , False ):
238- self .check_transaction ({'payment' : {'was_authorized' : good }})
239- for bad in ('' , 0 , 'True' ):
240- self .check_invalid_transaction (
241- {'payment' : {'was_authorized' : bad }})
249+ self .check_bool ('payment' , 'was_authorized' )
242250
243251 def test_decline_code (self ):
244252 self .check_str_type ('payment' , 'decline_code' )
@@ -251,9 +259,6 @@ def test_category(self):
251259 def test_item_id (self ):
252260 self .check_transaction ({'shopping_cart' : [{'item_id' : 'cat' }]})
253261
254- def test_item_id (self ):
255- self .check_transaction ({'shopping_cart' : [{'item_id' : 'cat' }]})
256-
257262 def test_amount (self ):
258263 self .check_positive_number (lambda v : {'shopping_cart' : [{'price' : v }]})
259264
0 commit comments