aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_processing.py
diff options
context:
space:
mode:
authorBrett Smith <brettcsmith@brettcsmith.org>2012-03-25 12:11:13 -0400
committerBrett Smith <brettcsmith@brettcsmith.org>2012-03-25 12:11:13 -0400
commit095fbdaf8d165dae390c4fb61b888309056b8fe6 (patch)
tree64397fbaee4baeefce2ff81aca68897a92b3b796 /mediagoblin/tests/test_processing.py
parent6573573dd1650a73fe058df43dfb5770217b2afa (diff)
downloadmediagoblin-095fbdaf8d165dae390c4fb61b888309056b8fe6.tar.lz
mediagoblin-095fbdaf8d165dae390c4fb61b888309056b8fe6.tar.xz
mediagoblin-095fbdaf8d165dae390c4fb61b888309056b8fe6.zip
Add FilenameMunger class to processing, with tests.
Munging filenames is something all media type processors want to be able to do, so I'm refactoring it out into a nice bite-sized class.
Diffstat (limited to 'mediagoblin/tests/test_processing.py')
-rw-r--r--mediagoblin/tests/test_processing.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_processing.py b/mediagoblin/tests/test_processing.py
new file mode 100644
index 00000000..6f3fad70
--- /dev/null
+++ b/mediagoblin/tests/test_processing.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+from nose.tools import assert_equal, assert_true, assert_false
+
+from mediagoblin import processing
+
+class TestProcessing(object):
+ def run_munge(self, input, format, output=None):
+ munger = processing.FilenameMunger(input)
+ result = munger.munge(format)
+ if output is None:
+ return result
+ assert_equal(output, result)
+
+ def test_easy_filename_munge(self):
+ self.run_munge('/home/user/foo.TXT', '{basename}bar{ext}', 'foobar.txt')
+
+ def test_long_filename_munge(self):
+ self.run_munge('{0}.png'.format('A' * 300), 'image-{basename}{ext}',
+ 'image-{0}.png'.format('A' * 245))