#NEWLINE# @ patch . object ( R , '_categorize' ) #NEWLINE# def test_metric_with_category( self , mock_categorize ) : #NEWLINE# #INDENT# 'The ``metric`` method should call ``_categorize`` if passed a\n        ``category`` argument.' #NEWLINE# category = 'Some Category' #NEWLINE# slug = 'categorized-metric' #NEWLINE# n = 1 #NEWLINE# keys = self . r . _build_keys ( slug ) #NEWLINE# ( second , minute , hour , day , week , month , year ) = keys #NEWLINE# self . r . metric ( slug , num = n , category = category ) #NEWLINE# self . redis . assert_has_calls ( [ call . sadd ( self . r . _metric_slugs_key , slug ) , call . pipeline ( ) , call . pipeline ( ) . incr ( second , n ) , call . pipeline ( ) . incr ( minute , n ) , call . pipeline ( ) . incr ( hour , n ) , call . pipeline ( ) . incr ( day , n ) , call . pipeline ( ) . incr ( week , n ) , call . pipeline ( ) . incr ( month , n ) , call . pipeline ( ) . incr ( year , n ) ] ) #NEWLINE# mock_categorize . assert_called_once_with ( slug , category ) #NEWLINE# self . assertFalse ( self . redis . expire . called )