11# -*- coding: utf-8 -*-
22
3- from system_tests import CaseMeta , CopyTmpFiles , DeleteFiles , path , FileDecoratorBase
3+ from system_tests import CaseMeta , CopyFiles , CopyTmpFiles , DeleteFiles , path , FileDecoratorBase
44
55###########################################################
66# rename with different formats
1212
1313@CopyTmpFiles ("$data_path/" + infile )
1414@DeleteFiles ("$tmp_path/" + outfile )
15- class Rename1 (metaclass = CaseMeta ):
15+ class Rename_dbY (metaclass = CaseMeta ):
1616 infilename = path ("$tmp_path/" + infile )
1717 outfilename = path ("$tmp_path/" + outfile )
1818 commands = [
@@ -34,7 +34,7 @@ class Rename1(metaclass=CaseMeta):
3434
3535@CopyTmpFiles ("$data_path/" + infile )
3636@DeleteFiles ("$tmp_path/" + outfile )
37- class Rename2 (metaclass = CaseMeta ):
37+ class Rename_YmdHM (metaclass = CaseMeta ):
3838 infilename = path ("$tmp_path/" + infile )
3939 outfilename = path ("$tmp_path/" + outfile )
4040 commands = [
@@ -56,7 +56,7 @@ class Rename2(metaclass=CaseMeta):
5656
5757@CopyTmpFiles ("$data_path/" + infile )
5858@DeleteFiles ("$tmp_path/" + outfile )
59- class Rename3 (metaclass = CaseMeta ):
59+ class Rename_ExifTags (metaclass = CaseMeta ):
6060 infilename = path ("$tmp_path/" + infile )
6161 outfilename = path ("$tmp_path/" + outfile )
6262 commands = [
@@ -78,7 +78,7 @@ class Rename3(metaclass=CaseMeta):
7878
7979@CopyTmpFiles ("$data_path/" + infile )
8080@DeleteFiles ("$tmp_path/" + outfile )
81- class Rename4 (metaclass = CaseMeta ):
81+ class Rename_ExifTagsInvalidChar (metaclass = CaseMeta ):
8282 infilename = path ("$tmp_path/" + infile )
8383 outfilename = path ("$tmp_path/" + outfile )
8484 commands = [
@@ -97,6 +97,36 @@ class Rename4(metaclass=CaseMeta):
9797 stderr = ["" ] * len (commands )
9898 retval = [0 ] * len (commands )
9999
100+ ###########################################################
101+ # rename with keeping suffix
102+ ###########################################################
103+
104+ basename = "_DSC8437"
105+ outfile = "02_Sep_2018.PANO.exv"
106+ renformat = "%d_%b_%Y:basesuffix:"
107+
108+ @CopyTmpFiles ("$data_path/_DSC8437.exv" )
109+ @DeleteFiles ("$tmp_path/" + outfile )
110+ class Rename_basesuffix (metaclass = CaseMeta ):
111+ infilename1 = path ("$tmp_path/" + basename + ".exv" )
112+ infilename2 = path ("$tmp_path/" + basename + ".PANO.exv" )
113+ outfilename = path ("$tmp_path/" + outfile )
114+ commands = [
115+ # first command to prepare a file name with suffix
116+ "$exiv2 --verbose --rename :basename:.PANO " + infilename1 ,
117+ "$exiv2 --verbose --rename " + renformat + " " + infilename2
118+ ]
119+ stdout = [
120+ """File 1/1: $infilename1
121+ Renaming file to $infilename2
122+ """ ,
123+ """File 1/1: $infilename2
124+ Renaming file to $outfilename
125+ """
126+ ]
127+ stderr = ["" ] * len (commands )
128+ retval = [0 ] * len (commands )
129+
100130###########################################################
101131# rename error: tag is not included
102132###########################################################
@@ -107,7 +137,7 @@ class Rename4(metaclass=CaseMeta):
107137
108138@CopyTmpFiles ("$data_path/" + infile )
109139@DeleteFiles ("$tmp_path/" + outfile )
110- class RenameError1 (metaclass = CaseMeta ):
140+ class Rename_TagNotIncluded (metaclass = CaseMeta ):
111141 infilename = path ("$tmp_path/" + infile )
112142 outfilename = path ("$tmp_path/" + outfile )
113143 commands = [
@@ -123,27 +153,35 @@ class RenameError1(metaclass=CaseMeta):
123153 retval = [0 ] * len (commands )
124154
125155###########################################################
126- # rename error: unbalanced colon
156+ # rename error: file contains no Exif data
127157###########################################################
128158
129159infile = "_DSC8437.exv"
130160outfile = "_DSC8437_.exv"
131- renformat = ":basename:_Exif .Image.ImageDescription:"
161+ renformat = ":basename:_:Exif .Image.ImageDescription:"
132162
133163@CopyTmpFiles ("$data_path/" + infile )
134- @DeleteFiles ("$tmp_path/" + outfile )
135- class RenameError2 (metaclass = CaseMeta ):
164+ # @DeleteFiles("$tmp_path/" + outfile)
165+ class Rename_NoExifData (metaclass = CaseMeta ):
136166 infilename = path ("$tmp_path/" + infile )
137167 outfilename = path ("$tmp_path/" + outfile )
138168 commands = [
169+ "$exiv2 --delete a " + infilename ,
139170 "$exiv2 --verbose --rename " + renformat + " " + infilename
140171 ]
141172 stdout = [
173+ "" ,
142174 """File 1/1: $infilename
143- Renaming file to $outfilename
144175"""
145176 ]
146- stderr = ["""Warning: Exif.Image.ImageDescription is not included.
177+ stderr = ["" ,
178+ """$infilename: No Exif data found in the file
147179""" ]
148- retval = [0 ] * len (commands )
180+ retval = [0 , 253 ]
181+
182+ # ###########################################################
183+ # # rename error: unbalanced colon
184+ # ###########################################################
185+
186+
149187
0 commit comments