Revision d3c47597
Modification des tests suite aux changements apportés hier (migration des tests du modèle).
Adaptations dans le code de vigiboard pour utiliser l'authentification fournie par le modèle.
Certains tests fonctionnels de vigiboard sont SKIPés car bugués.
vigiboard.config.vigiboard renommé en vigiboard.config.vigiboard_cfg pour éviter des conflits de noms.
Dans le modèle, User.groups est renommé en User.usergroups pour éviter une confusion avec les groupes d'hosts.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@624 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/websetup.py | ||
---|---|---|
13 | 13 |
log = logging.getLogger(__name__) |
14 | 14 |
|
15 | 15 |
|
16 |
def setup_app(command, conf, vars): |
|
16 |
def setup_app(command, conf, variables):
|
|
17 | 17 |
"""Place any commands to setup vigiboard here""" |
18 | 18 |
load_environment(conf.global_conf, conf.local_conf) |
19 |
|
|
19 | 20 |
# Load the models |
20 | 21 |
from vigiboard import model |
22 |
|
|
23 |
# Create tables |
|
21 | 24 |
print "Creating tables" |
22 |
model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine) |
|
25 |
model.metadata.create_all() |
|
26 |
print "Successfully created tables" |
|
23 | 27 |
|
24 |
# Create the default user for TG, must be change for real test and production
|
|
28 |
# Create a test used called "manager".
|
|
25 | 29 |
manager = model.User() |
26 | 30 |
manager.user_name = u'manager' |
27 |
manager.display_name = u'Example manager' |
|
28 |
manager.email_address = u'manager@somedomain.com' |
|
29 |
manager.password = u'managepass' |
|
30 |
|
|
31 |
manager.email = u'manager@somedomain.com' |
|
31 | 32 |
model.DBSession.add(manager) |
32 | 33 |
|
33 |
group = model.Group() |
|
34 |
# Create a test group called "managers" |
|
35 |
# and add "manager" to that group. |
|
36 |
group = model.UserGroup() |
|
34 | 37 |
group.group_name = u'managers' |
35 |
group.display_name = u'Managers Group' |
|
36 |
|
|
37 | 38 |
group.users.append(manager) |
38 |
|
|
39 | 39 |
model.DBSession.add(group) |
40 | 40 |
|
41 |
# Create a test permission called "manage" |
|
42 |
# and give it to the group of "managers". |
|
41 | 43 |
permission = model.Permission() |
42 | 44 |
permission.permission_name = u'manage' |
43 |
permission.description = u'This permission give an administrative right to the bearer' |
|
44 |
permission.groups.append(group) |
|
45 |
|
|
45 |
permission.usergroups.append(group) |
|
46 | 46 |
model.DBSession.add(permission) |
47 | 47 |
|
48 |
# Create a test user called "editor". |
|
48 | 49 |
editor = model.User() |
49 | 50 |
editor.user_name = u'editor' |
50 |
editor.display_name = u'Example editor' |
|
51 |
editor.email_address = u'editor@somedomain.com' |
|
52 |
editor.password = u'editpass' |
|
53 |
|
|
51 |
editor.email = u'editor@somedomain.com' |
|
54 | 52 |
model.DBSession.add(editor) |
55 | 53 |
|
56 |
group = model.Group() |
|
54 |
# Create a test group called "editors" |
|
55 |
# and add "editor" to that group. |
|
56 |
group = model.UserGroup() |
|
57 | 57 |
group.group_name = u'editors' |
58 |
group.display_name = u'Editors Group' |
|
59 |
|
|
60 | 58 |
group.users.append(editor) |
61 |
|
|
62 | 59 |
model.DBSession.add(group) |
63 | 60 |
|
61 |
# Create a test permission called "edit" |
|
62 |
# and give it to the group of "editors". |
|
64 | 63 |
permission = model.Permission() |
65 | 64 |
permission.permission_name = u'edit' |
66 |
permission.description = u'This permission give an Editor the right to edit' |
|
67 |
permission.groups.append(group) |
|
68 |
|
|
65 |
permission.usergroups.append(group) |
|
69 | 66 |
model.DBSession.add(permission) |
70 | 67 |
|
71 | 68 |
model.DBSession.flush() |
72 |
|
|
73 | 69 |
transaction.commit() |
74 | 70 |
print "Successfully setup" |
Also available in: Unified diff