Hi everybody,

First of all, thank you Massimo for your great framework and thanks to
all the community who helped me much by posting answers and snippets
to AlterEgo, the wiki or on the group.

I've spent quite a time (sorry i am quite a beginner) for my Unit test
to work because my controller check if my user has_membership.

Thus, here is a little snippet to add in the setUp method of the test
Class :

        ## Automatically adds a user to the database ##
        #hash the password
        password=db.auth_user.password.requires[0]('password')[0]
        #create a fake user
        user_id =
db.auth_user.insert(first_name="Unittest",last_name="setUp",email="usern...@domain.com",password=password)
        #add wanted membership (if needed)
        auth.add_membership(auth.id_group("Manager"),user_id)
        #log user in
        auth.login_bare("usern...@domain.com","password")

Hope that will help anybody, if not, sorry for beating a dead horse,

Jérémie

PS : i am using a test_db so it does not modify my dev database

Reply via email to