File: test_models.py

package info (click to toggle)
python-django-rules 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: python: 1,613; makefile: 5; sh: 3
file content (22 lines) | stat: -rw-r--r-- 660 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from __future__ import absolute_import

from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase

import rules


class RulesModelTests(TestCase):
    def test_preprocess(self):
        self.assertTrue(rules.perm_exists("testapp.add_testmodel"))
        self.assertTrue(rules.perm_exists("testapp.custom_testmodel"))

    def test_invalid_config(self):
        from rules.contrib.models import RulesModel

        with self.assertRaises(ImproperlyConfigured):

            class InvalidTestModel(RulesModel):
                class Meta:
                    app_label = "testapp"
                    rules_permissions = "invalid"