def test_date_setting(self): datefile = Dated_file("/path/2003_10_02_test_file.txt") datefile.set_date("2005_11_04") self.assertEqual( datefile.get_date(), "2005_11_04" )
def test_test_date_found(self): ''' if there is no date and older file don't exist we should set the \ current date. ''' datefile = Dated_file("/path/2003_10_02_test_file.txt") self.assertEqual( datefile.get_date(), "2003_10_02" )
def test_set_to_dated_existing_folder(self): datefile = Dated_file("./data/examples/2004_12_02_test_folder") self.assertEqual( datefile.get_date(), "2004_12_02" ) self.assertEqual( datefile.get_file_name(), "test_folder" ) self.assertEqual( datefile.get_full_file_name(), "2004_12_02_test_folder" )
def test_set_to_last_existing_file(self): datefile = Dated_file("./data/examples/test_file.txt") self.assertEqual( datefile.get_date(), "2006_02_08" ) self.assertEqual( datefile.get_file_name(), "test_file.txt" ) self.assertEqual( datefile.get_full_file_name(), "2006_02_08_test_file.txt" )
def test_test_no_date_found(self): ''' if there is no date and older file don't exist we should set the \ current date. ''' datefile = Dated_file("/path/test_file.txt") current_date = datetime.date.today() self.assertEqual( datefile.get_date(), current_date.strftime("%Y_%m_%d") ) self.assertEqual( datefile.get_full_file_name(), current_date.strftime("%Y_%m_%d_") + "test_file.txt" )