From 1c63ee3c06eeb5fe1d2dc9a0a81b536ce24d700e Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 9 Oct 2009 16:01:15 +0100 Subject: [PATCH] Added a small test for rtv_convert to confirm that the seconds are no longer included in filenames. --- src/rtv_convert.py | 44 +++++++++++++++++++++++++++++++++++--------- src/test_recordtv | 8 +++++++- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/rtv_convert.py b/src/rtv_convert.py index 2dbbf06..8746cbc 100644 --- a/src/rtv_convert.py +++ b/src/rtv_convert.py @@ -21,16 +21,9 @@ def _sanitise_filename( fn, max_len ): san_fn += "_" return san_fn[:max_len] -def _get_flv_file_path( rtvinfo, fallback_filename ): - if not os.path.isfile( rtvinfo ): - print "Error: rtvinfo file '%s' not found." % rtvinfo - sys.stdout.flush() - return ( "", fallback_filename ) - - proginfo = rtv_programmeinfo.ProgrammeInfo() - proginfo.load( rtvinfo ) +def _get_flv_file_path_from_proginfo( proginfo ): - startTime = str( proginfo.startTime ) + startTime = proginfo.startTime.strftime( "%Y-%m-%d_%H_%M" ) if proginfo.sub_title: unsan_file = startTime[:10] + "_" + str( proginfo.sub_title ) @@ -53,6 +46,18 @@ def _get_flv_file_path( rtvinfo, fallback_filename ): return ans + +def _get_flv_file_path( rtvinfo, fallback_filename ): + if not os.path.isfile( rtvinfo ): + print "Error: rtvinfo file '%s' not found." % rtvinfo + sys.stdout.flush() + return ( "", fallback_filename ) + + proginfo = rtv_programmeinfo.ProgrammeInfo() + proginfo.load( rtvinfo ) + + return _get_flv_file_path_from_proginfo( proginfo ) + def _delete_empty_dirs( config ): for ( dirpath, dirnames, filenames ) in os.walk( config.converted_progs_dir ): @@ -163,3 +168,24 @@ def rename( config ): _delete_empty_dirs( config ) +# ------ Test code ----- + +class FakeProgInfo: + pass + +def test( config ): + proginfo = FakeProgInfo() + from rtv_saxhandler import SaxHandler + saxhandler = SaxHandler( None ) + xmltv_time = "20091009094500 +0100" + proginfo.startTime = saxhandler.parse_time( xmltv_time ) + proginfo.sub_title = None + proginfo.channel_pretty = "My Channel" + proginfo.title = "My Programme" + proginfo.destination = None + + (flv_dir, flv_stem) = _get_flv_file_path_from_proginfo( proginfo ) + + assert( flv_dir == "My_Programme" ) + assert( flv_stem == "My_Programme/2009-10-09_09_45_My_Channel" ) + diff --git a/src/test_recordtv b/src/test_recordtv index 75eda7f..7cafc45 100755 --- a/src/test_recordtv +++ b/src/test_recordtv @@ -10,11 +10,17 @@ import test.schedule from rtv_config import GTVGConfig +class FakeOptions: + pass + def test_fast(): - config = GTVGConfig( [], [] ) + options = FakeOptions() + options.days = 1 + config = GTVGConfig( options, [] ) rtv_propertiesfile.test() rtv_schedule.test( config ) + rtv_convert.test( config ) def test_slow(): test.schedule.test_slow() -- 2.11.4.GIT