@@ -149,7 +149,16 @@ def test_custom_application_model_incorrect_format(self):
149
149
# Patch oauth2 settings to use a custom Application model
150
150
oauth2_settings .APPLICATION_MODEL = "IncorrectApplicationFormat"
151
151
152
- self .assertRaises (ImproperlyConfigured , get_application_model )
152
+ self .assertRaises (ValueError , get_application_model )
153
+
154
+ # Revert oauth2 settings
155
+ oauth2_settings .APPLICATION_MODEL = 'oauth2_provider.Application'
156
+
157
+ def test_custom_application_model_not_installed (self ):
158
+ # Patch oauth2 settings to use a custom Application model
159
+ oauth2_settings .APPLICATION_MODEL = "tests.ApplicationNotInstalled"
160
+
161
+ self .assertRaises (LookupError , get_application_model )
153
162
154
163
# Revert oauth2 settings
155
164
oauth2_settings .APPLICATION_MODEL = 'oauth2_provider.Application'
@@ -176,7 +185,16 @@ def test_custom_access_token_model_incorrect_format(self):
176
185
# Patch oauth2 settings to use a custom AccessToken model
177
186
oauth2_settings .ACCESS_TOKEN_MODEL = "IncorrectAccessTokenFormat"
178
187
179
- self .assertRaises (ImproperlyConfigured , get_access_token_model )
188
+ self .assertRaises (ValueError , get_access_token_model )
189
+
190
+ # Revert oauth2 settings
191
+ oauth2_settings .ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken'
192
+
193
+ def test_custom_access_token_model_not_installed (self ):
194
+ # Patch oauth2 settings to use a custom AccessToken model
195
+ oauth2_settings .ACCESS_TOKEN_MODEL = "tests.AccessTokenNotInstalled"
196
+
197
+ self .assertRaises (LookupError , get_access_token_model )
180
198
181
199
# Revert oauth2 settings
182
200
oauth2_settings .ACCESS_TOKEN_MODEL = 'oauth2_provider.AccessToken'
@@ -203,7 +221,16 @@ def test_custom_refresh_token_model_incorrect_format(self):
203
221
# Patch oauth2 settings to use a custom RefreshToken model
204
222
oauth2_settings .REFRESH_TOKEN_MODEL = "IncorrectRefreshTokenFormat"
205
223
206
- self .assertRaises (ImproperlyConfigured , get_refresh_token_model )
224
+ self .assertRaises (ValueError , get_refresh_token_model )
225
+
226
+ # Revert oauth2 settings
227
+ oauth2_settings .REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken'
228
+
229
+ def test_custom_refresh_token_model_not_installed (self ):
230
+ # Patch oauth2 settings to use a custom AccessToken model
231
+ oauth2_settings .REFRESH_TOKEN_MODEL = "tests.RefreshTokenNotInstalled"
232
+
233
+ self .assertRaises (LookupError , get_refresh_token_model )
207
234
208
235
# Revert oauth2 settings
209
236
oauth2_settings .REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken'
@@ -230,7 +257,16 @@ def test_custom_grant_model_incorrect_format(self):
230
257
# Patch oauth2 settings to use a custom Grant model
231
258
oauth2_settings .GRANT_MODEL = "IncorrectGrantFormat"
232
259
233
- self .assertRaises (ImproperlyConfigured , get_grant_model )
260
+ self .assertRaises (ValueError , get_grant_model )
261
+
262
+ # Revert oauth2 settings
263
+ oauth2_settings .GRANT_MODEL = 'oauth2_provider.Grant'
264
+
265
+ def test_custom_grant_model_not_installed (self ):
266
+ # Patch oauth2 settings to use a custom AccessToken model
267
+ oauth2_settings .GRANT_MODEL = "tests.GrantNotInstalled"
268
+
269
+ self .assertRaises (LookupError , get_grant_model )
234
270
235
271
# Revert oauth2 settings
236
272
oauth2_settings .GRANT_MODEL = 'oauth2_provider.Grant'
0 commit comments