def get_permission(name): permission = Permission.search(name) if not permission: permission = Permission( permission_name=name ) permission.add() return permission
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)
def test_should_return_none_given_invalid_name(self): permission = Permission.search("Non existent permission_name") self.assertEqual(permission, None)
def test_should_return_permission_given_valid_name(self): permission = Permission.search("Admin") self.assertEqual(permission, self.admin_permission)