test_util.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 import datetime
00005 
00006 from freezegun import freeze_time
00007 from nose.tools import assert_equal
00008 
00009 from jsk_data.util import filename_with_timestamp
00010 
00011 
00012 @freeze_time('1999-01-01 23:59:59')
00013 def test_filename_with_timestamp():
00014     stamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
00015     # originally no stamp
00016     filename = '/tmp/pr2-test-1.bag'
00017     expected = '/tmp/{}_pr2-test-1.bag'.format(stamp)
00018     assert_equal(expected, filename_with_timestamp(filename))
00019     # stamped
00020     filename = '/tmp/2015-01-01-23-59-59-pr2-test-999.bag'
00021     assert_equal(filename, filename_with_timestamp(filename))
00022     # wrong formated stamp
00023     filename = '/tmp/2015-01-01_23-59-59-pr2-test-999.bag'
00024     expected = '/tmp/{}_2015-01-01_23-59-59-pr2-test-999.bag'.format(stamp)
00025     assert_equal(expected, filename_with_timestamp(filename))


jsk_data
Author(s):
autogenerated on Fri Sep 8 2017 03:39:16