From 846593e20b63aaa380284e12b770c6b3b9d97180 Mon Sep 17 00:00:00 2001 From: RussellBallestrini Date: Tue, 8 Jan 2013 00:31:51 -0500 Subject: [PATCH] Added 4 tests, more test coverage needed --- test_ago.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/test_ago.py b/test_ago.py index 152a36c..50e410e 100644 --- a/test_ago.py +++ b/test_ago.py @@ -1,27 +1,37 @@ from ago import human -from ago import delta2dict from ago import delta2human +from ago import delta2dict + +from datetime import datetime +from datetime import timedelta + +PRESENT = datetime.now() +PAST = PRESENT - timedelta( 492, 58711, 45 ) # days, secs, ms +FUTURE = PRESENT + timedelta( 2, 12447, 963 ) # days, secs, ms + +PAST_DELTA = PRESENT - PAST +FUTURE_DELTA = FUTURE - PRESENT + +def test_human_is_string(): + assert 'str' in str(type(human( PAST ))) + +def test_delta2human_is_string(): + assert 'str' in str(type(delta2human( PAST_DELTA ))) + +def test_delta2dict_is_dict(): + assert 'dict' in str(type(delta2dict( PAST_DELTA ))) def test_output(): """Test and example usage""" - from datetime import datetime - from datetime import timedelta - - present = datetime.now() - past = present - timedelta( 492, 58711, 45 ) # days, secs, ms - future = present + timedelta( 2, 12447, 963 ) # days, secs, ms - - pdelta = present - past - fdelta = future - present print '\nTesting past:\n' - print delta2dict( pdelta ) - print 'Commented ' + delta2human( pdelta, 3 ) + ' ago' - print 'Commented ' + human( past ) + ' ago' + print delta2dict( PAST_DELTA ) + print 'Commented ' + delta2human( PAST_DELTA, 3 ) + ' ago' + print 'Commented ' + human( PAST ) + ' ago' print '\nTesting future:\n' - print delta2dict( fdelta ) - print 'Shutdown in ' + delta2human( fdelta, 3 ) - print 'Shutdown in ' + human( future ) + print delta2dict( FUTURE_DELTA ) + print 'Shutdown in ' + delta2human( FUTURE_DELTA, 3 ) + print 'Shutdown in ' + human( FUTURE ) print ''