@@ -841,3 +841,45 @@ def test_resolve_location_name_invalid(self):
841841 def test_resolve_location_name_not_exist (self ):
842842 exc = self .assertRaises (exceptions .SoftLayerError , self .ordering .resolve_location_name , "UNKNOWN_LOCATION_TEST" )
843843 self .assertIn ("does not exist" , str (exc ))
844+
845+ # https://github.com/softlayer/softlayer-python/issues/1425
846+ # Issues relating to checking prices based of the price.term relationship
847+ def test_issues1425_zeroterm (self ):
848+ category1 = {'categoryCode' : 'cat1' }
849+ price1 = {'id' : 1234 , 'locationGroupId' : '' , "capacityRestrictionMaximum" : "16" ,
850+ "capacityRestrictionMinimum" : "1" , "capacityRestrictionType" : "STORAGE_SPACE" ,
851+ 'categories' : [category1 ], 'termLength' : 36 }
852+ price2 = {'id' : 45678 , 'locationGroupId' : '' , "capacityRestrictionMaximum" : "16" ,
853+ "capacityRestrictionMinimum" : "1" , "capacityRestrictionType" : "STORAGE_SPACE" ,
854+ 'categories' : [category1 ], 'termLength' : 0 }
855+
856+ # Test 0 termLength
857+ price_id = self .ordering .get_item_price_id ("8" , [price2 , price1 ])
858+ self .assertEqual (45678 , price_id )
859+
860+ # Test None termLength
861+ price2 ['termLength' ] = None
862+ price_id = self .ordering .get_item_price_id ("8" , [price2 , price1 ])
863+ self .assertEqual (45678 , price_id )
864+
865+ # Test '' termLength
866+ price2 ['termLength' ] = ''
867+ price_id = self .ordering .get_item_price_id ("8" , [price2 , price1 ])
868+ self .assertEqual (45678 , price_id )
869+
870+ def test_issues1425_nonzeroterm (self ):
871+ category1 = {'categoryCode' : 'cat1' }
872+ price1 = {'id' : 1234 , 'locationGroupId' : '' , "capacityRestrictionMaximum" : "16" ,
873+ "capacityRestrictionMinimum" : "1" , "capacityRestrictionType" : "STORAGE_SPACE" ,
874+ 'categories' : [category1 ], 'termLength' : 36 }
875+ price2 = {'id' : 45678 , 'locationGroupId' : '' , "capacityRestrictionMaximum" : "16" ,
876+ "capacityRestrictionMinimum" : "1" , "capacityRestrictionType" : "STORAGE_SPACE" ,
877+ 'categories' : [category1 ], 'termLength' : 0 }
878+
879+ # Test 36 termLength
880+ price_id = self .ordering .get_item_price_id ("8" , [price2 , price1 ], 36 )
881+ self .assertEqual (1234 , price_id )
882+
883+ # Test None-existing price for term
884+ price_id = self .ordering .get_item_price_id ("8" , [price2 , price1 ], 37 )
885+ self .assertEqual (None , price_id )
0 commit comments