summaryrefslogtreecommitdiff
path: root/ishtar_common/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r--ishtar_common/tests.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 8d85e3cba..defc3a0c3 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -376,7 +376,12 @@ class WizardTest(object):
class CacheTest(TestCase):
- def testAdd(self):
+ fixtures = [settings.ROOT_PATH +
+ '../fixtures/initial_data-auth-fr.json',
+ settings.ROOT_PATH +
+ '../ishtar_common/fixtures/initial_data-fr.json',]
+
+ def test_add(self):
models.OrganizationType.refresh_cache()
cached = models.OrganizationType.get_cache('test')
self.assertEqual(cached, None)
@@ -389,7 +394,7 @@ class CacheTest(TestCase):
cached = models.OrganizationType.get_cache('testy')
self.assertEqual(cached.pk, orga.pk)
- def testList(self):
+ def test_list(self):
models.OrganizationType.refresh_cache()
types = models.OrganizationType.get_types()
# only empty
@@ -404,6 +409,36 @@ class CacheTest(TestCase):
unicode(lbl) for idx, lbl in models.OrganizationType.get_types()]
self.assertFalse('testy' in types)
+ def test_menu_cache(self):
+ admin_username = 'username4277'
+ admin_password = 'dcbqj756456!@%'
+ User.objects.create_superuser(admin_username, "nomail@nomail.com",
+ admin_password)
+ readonly_user = 'username4456'
+ readonly_password = 'xshqu744456!@%'
+ user = User.objects.create_user(readonly_user, "nomail@nomail.com",
+ readonly_password)
+ ishtuser = models.IshtarUser.objects.get(user_ptr=user)
+ models.UserProfile.objects.get_or_create(
+ current=True, person=ishtuser.person,
+ profile_type=models.ProfileType.objects.get(
+ txt_idx='reader_access'))
+
+ c = Client()
+ c.login(username=admin_username, password=admin_password)
+ response = c.get("/operation_search/general-operation_search")
+ self.assertIn('href="/operation_modification/', response.content)
+
+ # the cache menu must be updated...
+ c2 = Client()
+ c2.login(username=readonly_user, password=readonly_password)
+ response = c2.get("/operation_search/general-operation_search")
+ self.assertNotIn('href="/operation_modification/', response.content)
+
+ # ... only on a session basis
+ response = c.get("/operation_search/general-operation_search")
+ self.assertIn('href="/operation_modification/', response.content)
+
class AccessControlTest(TestCase):
def test_administrator(self):
@@ -1339,7 +1374,7 @@ class IshtarSiteProfileTest(TestCase):
self.assertTrue(profile)
self.assertEqual(models.IshtarSiteProfile.objects.count(), 1)
- def testMenuFiltering(self):
+ def test_menu_filtering(self):
cache.set('default-ishtarsiteprofile-is-current-profile', None,
settings.CACHE_TIMEOUT)
username = 'username4277'
@@ -1349,7 +1384,7 @@ class IshtarSiteProfileTest(TestCase):
c = Client()
c.login(username=username, password=password)
response = c.get(reverse('start'))
- self.assertFalse("section-file_management" in response.content)
+ self.assertNotIn('href="/file_search/"', response.content)
profile = models.get_current_profile()
profile.files = True
profile.save()