diff options
Diffstat (limited to 'ishtar_common/tests.py')
| -rw-r--r-- | ishtar_common/tests.py | 32 | 
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) | 
