add unit test for unix os to test creation of contents without writing/reading permissions
--- a/src/ldt/ldt/ldt_utils/tests/content_tests.py Mon Nov 12 16:00:15 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/tests/content_tests.py Fri Nov 16 17:35:46 2012 +0100
@@ -17,6 +17,7 @@
import uuid
import logging
import os
+import exceptions
class ContentTest(TestCase):
@@ -30,7 +31,7 @@
self.user = User()
self.user.username = 'blop'
-
+
#test the creation of a content without media
def test_create_content_v1(self):
self.cont12 = Content(iriurl="id12/iriurl12", duration = 100)
@@ -48,7 +49,53 @@
self.cont13.save()
self.assertEqual(Content.objects.get(iri_id=self.cont13.iri_id), self.cont13)
-
+
+ #test the creation of content without reading permission
+ def test_create_content_v3(self):
+ import sys
+ ldt_dir = os.path.join(settings.MEDIA_ROOT, "ldt")
+ if sys.platform == 'win32':
+ logging.debug("windows 3")
+ else:
+ logging.debug("linux")
+ os.chmod(ldt_dir, 0577)
+
+ self.cont17 = Content(iriurl="id17/iriurl17", duration = 100)
+ self.cont17.iri_id = 'id117'
+ with self.assertRaises(WindowsError):
+ self.cont17.save()
+ with self.assertRaises(Content.DoesNotExist):
+ Content.objects.get(iri_id=self.cont17.iri_id)
+
+ if sys.platform == 'win32':
+ logging.debug("windows 4")
+ else:
+ logging.debug("linux")
+ os.chmod(ldt_dir, 0700)
+
+ #test the creation of content without reading permission
+ def test_create_content_v4(self):
+ import sys
+ ldt_dir = os.path.join(settings.MEDIA_ROOT, "ldt")
+ if sys.platform == 'win32':
+ logging.debug("windows 3")
+ else:
+ logging.debug("linux")
+ os.chmod(ldt_dir, 0377)
+
+ self.cont18 = Content(iriurl="id18/iriurl18", duration = 100)
+ self.cont18.iri_id = 'id118'
+ with self.assertRaises(WindowsError):
+ self.cont18.save()
+ with self.assertRaises(Content.DoesNotExist):
+ Content.objects.get(iri_id=self.cont18.iri_id)
+
+ if sys.platform == 'win32':
+ logging.debug("windows 4")
+ else:
+ logging.debug("linux")
+ os.chmod(ldt_dir, 0700)
+
#test the deletion of a content without media
def test_del_content_v1(self):
self.cont14 = Content(iriurl="id14/iriurl14", duration = 100)