make django tests working again, from ymh, see http://www.iri.centrepompidou.fr/dev/hg/comt/rev/e103299bccc0
authorgibus
Tue, 11 Mar 2014 11:06:37 +0100
changeset 606 52f3e090eed9
parent 605 830993bdf983
child 607 0cead418e4cb
make django tests working again, from ymh, see http://www.iri.centrepompidou.fr/dev/hg/comt/rev/e103299bccc0
src/cm/activity.py
src/cm/tests/test_api.py
src/cm/tests/test_comment_positioning.py
src/cm/tests/test_notifications.py
src/cm/tests/test_security.py
--- a/src/cm/activity.py	Tue Mar 11 11:05:25 2014 +0100
+++ b/src/cm/activity.py	Tue Mar 11 11:06:37 2014 +0100
@@ -31,7 +31,7 @@
         originator_user = request.user
     
     if STORE_ACTIVITY_IP:
-        ip = request.META['REMOTE_ADDR']
+        ip = request.META.get('REMOTE_ADDR', '0.0.0.0')
     else:
         ip = None
     
--- a/src/cm/tests/test_api.py	Tue Mar 11 11:05:25 2014 +0100
+++ b/src/cm/tests/test_api.py	Tue Mar 11 11:06:37 2014 +0100
@@ -22,7 +22,7 @@
         self.user = user
 
 class APITest(TestCase):
-    fixtures = ['roles_generic', 'test_content', ]
+    fixtures = ['initial_data','roles_generic', 'test_content', ]
     
     def test_text_get(self):
         """
--- a/src/cm/tests/test_comment_positioning.py	Tue Mar 11 11:05:25 2014 +0100
+++ b/src/cm/tests/test_comment_positioning.py	Tue Mar 11 11:06:37 2014 +0100
@@ -2,6 +2,7 @@
 from django.test import TestCase
 from BeautifulSoup import BeautifulSoup
 from cm.models import *
+from django.core.cache import cache
 
 # python manage.py test 

@@ -20,6 +21,7 @@
                            reply_to=reply_to,
                            state=state,
                            user=user)
+    cache.clear()
     return co
     
 
--- a/src/cm/tests/test_notifications.py	Tue Mar 11 11:05:25 2014 +0100
+++ b/src/cm/tests/test_notifications.py	Tue Mar 11 11:06:37 2014 +0100
@@ -7,7 +7,7 @@
 from cm.models_utils import *
 
 class NotificationTest(TestCase):
-    fixtures = ['roles_generic','test_content']
+    fixtures = ['initial_data', 'roles_generic','test_content']
     
     def setUp(self):
         pass
--- a/src/cm/tests/test_security.py	Tue Mar 11 11:05:25 2014 +0100
+++ b/src/cm/tests/test_security.py	Tue Mar 11 11:06:37 2014 +0100
@@ -1,7 +1,7 @@
 from django.test import TestCase
 from django.test.client import Client
 from django.core import management
-
+from django.core.cache import cache
 
 from cm.models import *
 from cm.security import *
@@ -12,7 +12,7 @@
         self.user = user
 
 class SecurityTest(TestCase):
-    fixtures = ['roles_generic','test_content']
+    fixtures = ['initial_data', 'roles_generic','test_content']
     
     def test_access_rights(self):
         # anon user sees no text
@@ -53,6 +53,7 @@
         c2.save()
         c3.state = 'approved'
         c3.save()
+        cache.clear()
 
         self.assertFalse(has_own_perm(FalseRequest(user3), "can_edit_comment" + "_own", text2, c3),'CANNOT edit own comment (there is a reply)')
         self.assertTrue(has_own_perm(FalseRequest(user2), "can_edit_comment" + "_own", text2, c2),"CAN edit own comment (is moderator)")
@@ -77,4 +78,4 @@
                 
         self.assertFalse(has_own_perm(FalseRequest(user3), "can_edit_comment" + "_own", text2, c3),'CANNOT edit own comment (there is a reply)')
         self.assertTrue(has_perm(FalseRequest(user2), "can_edit_comment", text2),"CAN edit other's comment (moderator)")
-        
\ No newline at end of file
+