Test coverage report: permission.exceptions

# permission.exceptions: 14 total statements, 46.2% covered

Generated: Thu 2012-03-01 14:22 CST

Source file: /home/alisue/Dropbox/Codes/django-permission/permission/exceptions.py

Stats: 6 executed, 7 missed, 1 excluded, 52 ignored

1. `# vim: set fileencoding=utf-8 :`
2. `"""`
3. `Exceptions used in this app.`
4. ``
5. `Exception:`
6. `ValidationError`
7. `raise when the passed permission handler is not valid.`
8. ``
9. `PermissinDetectionError`
10. `raise when the app could not detect the permission from string.`
11. ``
12. `AlreadyRegistered`
13. `raise when the handler of model is already registered in registry.`
14. ``
15. `NotRegistered`
16. `raise when the handler of model is not registered in registry.`
17. ``
18. ``
19. `AUTHOR:`
20. `lambdalisue[Ali su ae] (lambdalisue@hashnote.net)`
21. ``
22. `License:`
23. `The MIT License (MIT)`
24. ``
25. `Copyright (c) 2012 Alisue allright reserved.`
26. ``
27. `Permission is hereby granted, free of charge, to any person obtaining a copy`
28. `of this software and associated documentation files (the "Software"), to`
29. `deal in the Software without restriction, including without limitation the`
30. `rights to use, copy, modify, merge, publish, distribute, sublicense, and/or`
31. `sell copies of the Software, and to permit persons to whom the Software is`
32. `furnished to do so, subject to the following conditions:`
33. ``
34. `The above copyright notice and this permission notice shall be included in`
35. `all copies or substantial portions of the Software.`
36. ``
37. `THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR`
38. `IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,`
39. `FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE`
40. `AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER`
41. `LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING`
42. `FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS`
43. `IN THE SOFTWARE.`
44. ``
45. `"""`
46. `from __future__ import with_statement`
47. ``
48. `class ValidationError(Exception):`
49. `"""Validation error"""`
50. ``
51. `class PermissionDetectionError(Exception):`
52. `"""Permission detection error"""`
53. ``
54. `class AlreadyRegistered(Exception):`
55. `"""PermissionHandler of the model is already registered error"""`
56. `def __init__(self, model):`
57. `msg = 'Permission handler of the model "%s.%s" is already registered'`
58. `msg = msg % (model._meta.app_label, model.__class__.__name__)`
59. `super(AlreadyRegistered, self).__init__(msg)`
60. ``
61. `class NotRegistered(Exception):`
62. `"""PermissionHandler of the model is not registered error"""`
63. `def __init__(self, model):`
64. `msg = 'Permission handler of the model "%s.%s" is not registered'`
65. `msg = msg % (model._meta.app_label, model.__class__.__name__)`
66. `super(NotRegistered, self).__init__(msg)`