5
5
from django .contrib .auth .models import User
6
6
from milkman .dairy import milkman
7
7
from userroles .models import set_user_role , UserRole
8
- from userroles .testapp .models import ModeratorProfile
8
+ from userroles .testapp .models import TestModeratorProfile
9
9
from userroles .utils import SettingsTestCase
10
10
from userroles import Roles
11
11
12
12
# Test setup
13
13
14
14
roles_config = (
15
- ( 'manager' , '' ) ,
16
- ( 'moderator' , 'userroles.testapp.models.ModeratorProfile' ) ,
17
- ( 'client' , '' ) ,
15
+ 'manager' ,
16
+ 'moderator' ,
17
+ 'client' ,
18
18
)
19
19
20
20
installed_apps_config = list (settings .INSTALLED_APPS )
@@ -31,11 +31,11 @@ def setUp(self):
31
31
ROOT_URLCONF = 'userroles.testapp.urls' ,
32
32
USER_ROLES = roles_config
33
33
)
34
- self .restore_roles = UserRole .valid_roles
35
- UserRole .valid_roles = roles
34
+ self .restore_roles = UserRole ._valid_roles
35
+ UserRole ._valid_roles = roles
36
36
37
37
def tearDown (self ):
38
- UserRole .valid_roles = self .restore_roles
38
+ UserRole ._valid_roles = self .restore_roles
39
39
40
40
41
41
class DummyClass (object ):
@@ -113,30 +113,30 @@ def test_set_role_with_profile(self):
113
113
"""
114
114
Set a role that takes a profile.
115
115
"""
116
- set_user_role (self .user , roles .moderator , ModeratorProfile (stars = 5 ))
116
+ set_user_role (self .user , roles .moderator , TestModeratorProfile (stars = 5 ))
117
117
self .assertTrue (self .user .role .is_moderator )
118
118
self .assertEquals (self .user .role .profile .stars , 5 )
119
119
120
- def test_set_role_without_profile_incorrectly (self ):
121
- """
122
- Attempt to set a profile on a role that does not take a profile.
123
- """
124
- args = (self .user , roles .client , ModeratorProfile ())
125
- self .assertRaises (ValueError , set_user_role , * args )
126
-
127
- def test_set_role_with_profile_incorrectly (self ):
128
- """
129
- Attempt to set a role that uses profiles, without setting a profile.
130
- """
131
- args = (self .user , roles .moderator , )
132
- self .assertRaises (ValueError , set_user_role , * args )
133
-
134
- def test_set_role_with_profile_using_wrong_profile (self ):
135
- """
136
- Attempt to set a role that uses profiles, without setting a profile.
137
- """
138
- args = (self .user , roles .moderator , DummyClass ())
139
- self .assertRaises (ValueError , set_user_role , * args )
120
+ # def test_set_role_without_profile_incorrectly(self):
121
+ # """
122
+ # Attempt to set a profile on a role that does not take a profile.
123
+ # """
124
+ # args = (self.user, roles.client, ModeratorProfile())
125
+ # self.assertRaises(ValueError, set_user_role, *args)
126
+
127
+ # def test_set_role_with_profile_incorrectly(self):
128
+ # """
129
+ # Attempt to set a role that uses profiles, without setting a profile.
130
+ # """
131
+ # args = (self.user, roles.moderator, )
132
+ # self.assertRaises(ValueError, set_user_role, *args)
133
+
134
+ # def test_set_role_with_profile_using_wrong_profile(self):
135
+ # """
136
+ # Attempt to set a role that uses profiles, without setting a profile.
137
+ # """
138
+ # args = (self.user, roles.moderator, DummyClass())
139
+ # self.assertRaises(ValueError, set_user_role, *args)
140
140
141
141
142
142
# Tests for user role view decorators
0 commit comments