Commit 5121e80a518bcd046d9f867638e86edbe2289fb6

Authored by Odile@pc2050
1 parent 2a312522
Exists in master

Fix #4. Additional unit test to reflect changes in #2

Showing 2 changed files with 6 additions and 1 deletions   Show diff stats
src/files.py
... ... @@ -37,7 +37,7 @@ class PireneaFiles(object):
37 37 for path, _dirs, files in os.walk(self.folder):
38 38 for filename in files:
39 39 if filename.startswith("P"):
40   - print("File %s has already a prefix.")
  40 + print("File {0} has already a prefix.".format(filename))
41 41 else:
42 42 new_filename = prefix + filename
43 43 os.rename(os.path.join(path, filename), os.path.join(path, new_filename))
... ...
tests/test_files.py
... ... @@ -40,7 +40,12 @@ class PireneaFilesTestCase(unittest.TestCase):
40 40 with tempfile.TemporaryDirectory(prefix="PIRENEA_DATA") as tmpdirname:
41 41 with tempfile.TemporaryFile(dir=tmpdirname) as tf:
42 42 self.pirenea = PireneaFiles(tmpdirname)
  43 + # Check add prefix
43 44 self.pirenea.add_prefix("P0")
  45 + # Check if add prefix has no effect if already added
  46 + self.pirenea.add_prefix("P0")
  47 + self.pirenea.remove_prefix("P0")
  48 + # Check if remove prefix has no effect if file has no prefix
44 49 self.pirenea.remove_prefix("P0")
45 50 """Check if temporary file tf is unchanged"""
46 51 self.assertTrue(os.path.isfile(tf.name))
... ...