Пример #1
0
    def test_empty_get_by_user(self):
        user = User.objects.create(username='******')
        result = Permission.get_by_user(user)

        self.assertEqual(len(result['sites_id']), 0)
        self.assertEqual(len(result['all_sites_id']), 0)
        self.assertEqual(len(result['channels_id']), 0)
        self.assertEqual(len(result['channels_sites_id']), 0)
Пример #2
0
    def test_empty_get_by_user(self):
        user = User.objects.create(username='******')
        result = Permission.get_by_user(user)

        self.assertEqual(len(result['sites_id']), 0)
        self.assertEqual(len(result['all_sites_id']), 0)
        self.assertEqual(len(result['channels_id']), 0)
        self.assertEqual(len(result['channels_sites_id']), 0)
Пример #3
0
    def test_get_by_user_with_user_permission(self):
        user = User.objects.create(username='******')
        site = Site.objects.all()[0]
        channel = Channel.objects.create(name='Home',
                                         slug='home',
                                         site=site,
                                         user=user)
        permission = Permission.objects.create(user=user)
        permission.channel.add(channel)
        permission.save()

        result = Permission.get_by_user(user)

        self.assertTrue(site.pk in result['all_sites_id'])
        self.assertTrue(channel.pk in result['channels_id'])
Пример #4
0
    def test_get_by_user_with_user_permission(self):
        user = User.objects.create(username='******')
        site = Site.objects.all()[0]
        channel = Channel.objects.create(
            name='Home',
            slug='home',
            site=site,
            user=user
        )
        permission = Permission.objects.create(user=user)
        permission.channel.add(channel)
        permission.save()

        result = Permission.get_by_user(user)

        self.assertTrue(site.pk in result['all_sites_id'])
        self.assertTrue(channel.pk in result['channels_id'])