#NEWLINE# def test_metric_history_with_date( self ) : #NEWLINE# #INDENT# with patch ( 'redis_metrics.templatetags.redis_metric_tags.get_r' ) as mock_r : #NEWLINE# #INDENT# history = [ ( 'm:test:2000-01-01' , 42 ) ] #NEWLINE# inst = mock_r . return_value #NEWLINE# inst . get_metric_history . return_value = history #NEWLINE# expected_result = { #NEWLINE# #INDENT# 'slug' : 'test' , #NEWLINE# 'granularity' : 'daily' , #NEWLINE# 'metric_history' : history , #NEWLINE# 'since' : None , #NEWLINE# 'to' : None , #NEWLINE# 'with_data_table' : False , #NEWLINE# #UNINDENT# } #NEWLINE# since = datetime ( 2000 , 1 , 2 ) #NEWLINE# expected_result [ 'since' ] = since #NEWLINE# result = taglib . metric_history ( 'test' , since = '2000-01-02' ) #NEWLINE# self . assertEqual ( result , expected_result ) #NEWLINE# inst . get_metric_history . assert_called_once_with ( slugs = 'test' , granularity = 'daily' , since = since , to = None ) #NEWLINE# inst . reset_mock ( ) #NEWLINE# since = datetime ( 2000 , 1 , 2 , 11 , 30 , 45 ) #NEWLINE# expected_result [ 'since' ] = since #NEWLINE# result = taglib . metric_history ( 'test' , since = '2000-01-02 11:30:45' ) #NEWLINE# self . assertEqual ( result , expected_result ) #NEWLINE# inst . get_metric_history . assert_called_once_with ( slugs = 'test' , granularity = 'daily' , since = since , to = None ) #NEWLINE# inst . reset_mock ( ) #NEWLINE# since = datetime ( 2000 , 1 , 2 , 11 , 30 , 45 ) #NEWLINE# expected_result [ 'since' ] = since #NEWLINE# result = taglib . metric_history ( 'test' , since = since ) #NEWLINE# self . assertEqual ( result , expected_result ) #NEWLINE# inst . get_metric_history . assert_called_once_with ( slugs = 'test' , granularity = 'daily' , since = since , to = None ) #NEWLINE# inst . reset_mock ( ) #NEWLINE# since = datetime ( 2000 , 1 , 2 , 11 , 30 , 45 ) #NEWLINE# to = datetime ( 2001 , 1 , 2 , 11 , 30 , 45 ) #NEWLINE# expected_result [ 'since' ] = since #NEWLINE# expected_result [ 'to' ] = to #NEWLINE# result = taglib . metric_history ( 'test' , since = since , to = to ) #NEWLINE# self . assertEqual ( result , expected_result ) #NEWLINE# inst . get_metric_history . assert_called_once_with ( slugs = 'test' , granularity = 'daily' , since = since , to = to )