author: Job van Achterberg
date: Wed Jul 31 14:50:57 2013 +0200
revision: 11850:913fc5451b2f in Products.Silva
branch: 2.4
details: https://hg.infrae.com/Products.Silva?cmd=changeset;node=913fc5451b2f
modified: Products/Silva/tests/test_file.py
added:
removed:
log: file upload test: tighten uniqueness checks, verify correct
uploading
diffstat:
Products/Silva/tests/test_file.py | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diffs (33 lines):
diff -r be1f582902af -r 913fc5451b2f Products/Silva/tests/test_file.py
--- a/Products/Silva/tests/test_file.py Wed Jul 31 12:05:12 2013 +0200
+++ b/Products/Silva/tests/test_file.py Wed Jul 31 14:50:57 2013 +0200
@@ -56,12 +56,25 @@
'modificationtime': DateTime('2010-04-25T12:00:00Z')})
return content
- def test_duplicate_id(self):
+ def test_upload_file_with_existing_id(self):
"""Test whether a file upload with a duplicate ID throws a ValueError
"""
- self.create_test_file('test1.zip')
- with self.assertRaises(ValueError):
- self.create_test_file('test1.zip')
+ factory = self.root.manage_addProduct['Silva']
+
+ with self.layer.open_fixture('photo.tif') as test_file:
+ factory.manage_addFile('test_file_id', 'Test File 1', test_file)
+ with self.assertRaises(ValueError) as error:
+ factory.manage_addImage('test_file_id', 'Test File 2',
+ test_file)
+
+ self.assertEqual(str(error.exception), "Please provide a unique id: ${reason}")
+
+ with self.layer.open_fixture('photo.tif') as test_file:
+ factory.manage_addFile('test_file_unique_id', 'Test File 3', test_file)
+
+ content = self.root._getOb('test_file_unique_id')
+ self.assertTrue(verifyObject(interfaces.IAsset, content))
+ self.assertTrue(verifyObject(interfaces.IFile, content))
def test_content_image(self):
"""Test base content methods on a file that contains an image.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.