summaryrefslogtreecommitdiff
path: root/ishtar_common/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-18 13:10:24 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-18 13:10:24 +0100
commit3c0e0b475481b3e4bb10f8174a419a24e9bb9948 (patch)
treeabac5732281694b364c299124a53f2cf446f572c /ishtar_common/tests.py
parente264115195002ee05658f59e8943b22460903e74 (diff)
downloadIshtar-3c0e0b475481b3e4bb10f8174a419a24e9bb9948.tar.bz2
Ishtar-3c0e0b475481b3e4bb10f8174a419a24e9bb9948.zip
Update tests for module management
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r--ishtar_common/tests.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index e2c9b233f..82ab009e0 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -17,10 +17,14 @@
# See the file COPYING for details.
+from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
+from django.core.cache import cache
+from django.core.urlresolvers import reverse
from django.template.defaultfilters import slugify
from django.test import TestCase
+from django.test.client import Client
from ishtar_common import models
@@ -161,16 +165,19 @@ class ImportKeyTest(TestCase):
class IshtarSiteProfileTest(TestCase):
def testRelevance(self):
- profile = models.IshtarSiteProfile.objects.create(
- label="Test profile", slug='test-profile')
+ cache.set('default-ishtarsiteprofile-is-current-profile', None,
+ settings.CACHE_TIMEOUT)
+ profile = models.get_current_profile()
+ default_slug = profile.slug
profile2 = models.IshtarSiteProfile.objects.create(
label="Test profile 2", slug='test-profile-2')
+ profile2.save()
# when no profile is the current, activate by default the first created
self.assertTrue(profile.active and not profile2.active)
profile2.active = True
profile2 = profile2.save()
- profile = models.IshtarSiteProfile.objects.get(slug='test-profile')
# only one profile active at a time
+ profile = models.IshtarSiteProfile.objects.get(slug=default_slug)
self.assertTrue(profile2.active and not profile.active)
# activate find active automatically context records
self.assertFalse(profile.context_record)
@@ -184,7 +191,26 @@ class IshtarSiteProfileTest(TestCase):
self.assertTrue(profile2.context_record and profile2.find)
def testDefaultProfile(self):
+ cache.set('default-ishtarsiteprofile-is-current-profile', None,
+ settings.CACHE_TIMEOUT)
self.assertFalse(models.IshtarSiteProfile.objects.count())
profile = models.get_current_profile()
self.assertTrue(profile)
self.assertTrue(models.IshtarSiteProfile.objects.count())
+
+ def testMenuFiltering(self):
+ cache.set('default-ishtarsiteprofile-is-current-profile', None,
+ settings.CACHE_TIMEOUT)
+ username = 'username4277'
+ password = 'dcbqj756456!@%'
+ User.objects.create_superuser(username, "nomail@nomail.com",
+ password)
+ c = Client()
+ c.login(username=username, password=password)
+ response = c.get(reverse('start'))
+ self.assertFalse("section-file_management" in response.content)
+ profile = models.get_current_profile()
+ profile.files = True
+ profile.save()
+ response = c.get(reverse('start'))
+ self.assertTrue("section-file_management" in response.content)