#NEWLINE# @ patch . object ( R , '_build_keys' ) #NEWLINE# def test_set_metric_with_expiration( self , mock_build_keys ) : #NEWLINE# #INDENT# 'Test setting metrics using ``R.set_metric`` with an expiration.' #NEWLINE# mock_build_keys . return_value = [ 'm:test-slug:s:2000-01-02-11-45-30' , 'm:test-slug:i:2000-01-02-11-45' , 'm:test-slug:h:2000-01-02-11' , 'm:test-slug:2000-01-02' , 'm:test-slug:m:2000-01' , 'm:test-slug:w:2000-01' , 'm:test-slug:y:2000' ] #NEWLINE# slug = 'test-slug' #NEWLINE# value = 42 #NEWLINE# self . r . set_metric ( slug , value , expire = 500 ) #NEWLINE# self . redis . expire . assert_has_calls ( [ call ( 'm:test-slug:s:2000-01-02-11-45-30' , 500 ) , call ( 'm:test-slug:i:2000-01-02-11-45' , 500 ) , call ( 'm:test-slug:h:2000-01-02-11' , 500 ) , call ( 'm:test-slug:2000-01-02' , 500 ) , call ( 'm:test-slug:m:2000-01' , 500 ) , call ( 'm:test-slug:w:2000-01' , 500 ) , call ( 'm:test-slug:y:2000' , 500 ) ] )