Beispiel #1
0
def create_admin_user():
    from EnGo.models.permission import Permission
    from EnGo.models.user import User
    admin_permission = Permission(permission_name="Admin")
    admin_permission.add()
    admin_user = User(username="******",
                      password=generate_password_hash('0000'))
    admin_user.add()
    admin_user.add_permission(admin_permission)
Beispiel #2
0
def create_dev_user():
    from EnGo.models.permission import Permission
    from EnGo.models.user import User
    dev_permission = Permission.search("Dev")
    if not dev_permission:
        dev_permission = Permission(permission_name="Dev")
        dev_permission.add()
    dev_user = User(username="******", password=generate_password_hash('0000'))
    dev_user.add()
    dev_user.add_permission(dev_permission)
class UserPermissionTest(UserTest):
    def setUp(self):
        UserTest.setUp(self)
        self.admin_permission = Permission(permission_name="Admin")
        self.admin_permission.add()
        self.admin_view = View(view_name="Admin View")
        self.admin_view.add()
        self.admin_view.add_permission(self.admin_permission)
        self.admin_user = User(username="******", password="******")
        self.admin_user.add()
        self.admin_user.add_permission(self.admin_permission)
        self.quality_permission = Permission(permission_name="quality")
        self.quality_permission.add()
        self.quality_view = View(view_name="Quality View")
        self.quality_view.add()
        self.quality_view.add_permission(self.quality_permission)
        self.normal_user = User(username="******", password="******")
        self.normal_user.add()
    def test_shoul_add_permission_to_user(self):
        user = User(username="******", password="******")
        user.add()
        user.add_permission(self.quality_permission)

        self.assertIn(self.quality_permission, user.permissions)