Exemple #1
0
    def test_create_permission_using_model(self):
        conditions = [{'some_condition': 'value'}]
        action = 'some_action'

        create_permission(user=self.batman, action=action,
            conditions=conditions, model_class=User)

        user_content_type = ContentType.objects.get_for_model(User)
        self.assertTrue(
            ACL.objects.filter(action=action, user=self.batman,
                lookup__content_type=user_content_type).exists()
        )
Exemple #2
0
    def test_create_permission_using_ct_natural_key(self):
        conditions = [{'some_condition': 'value'}]
        action = 'some_action'

        create_permission(user=self.batman, action=action,
            conditions=conditions, app_label='auth', model_name='user')

        user_content_type = ContentType.objects.get_for_model(User)
        self.assertTrue(
            ACL.objects.filter(action=action, user=self.batman,
                lookup__content_type=user_content_type).exists()
        )