def test_update_nonexistent(self): self.assertFalse( AccountManager.update_group(102, Group(**updated_group)))
def test_change_id(self): self.assertFalse( AccountManager.update_group(start_id, Group(**updated_group)))
def put(): json_data = request.get_json(force=True) if not json_data: return {'message': 'No input data provided'}, 400 data, errors = group_update_request_schema.load(json_data) if errors: return errors, 422 from AccountManager.account_manager import AccountManager results = False if "command" in data and "platform_ids" in data: if data["command"] == "attach": for plat in data["platform_ids"]: results = AccountManager.attach_platform( data["group_id"], plat) if not results: print("Failed to attach {} to group {}".format( plat, data["group_id"])) continue plat_info = DatabaseHandler.find('platforms', plat) for current in plat_info['subplatforms']: if 'Rocketchat' == current['name']: platform_man = PlatformManagerInstance.get_instance( ) # running = platform_man.getPlatformStatus(plat_info['main']['id'], current['id']) running = True if not running: platform_man.platform_interface.startPlatform( plat_info['main']['id'], current['id']) group_info = DatabaseHandler.find( 'groups', data["group_id"]) command = {'command': 'registerUser', 'param': {}} for user in group_info['members']: command['param']['username'] = user command['param'][ 'email'] = user + "@citsystem.com" user_info = DatabaseHandler.find('users', user) command['param']['password'] = user_info[ 'password'] success, user_id = platform_man.platform_interface.requestHandler( plat_info['main']['id'], current['id'], command) if not success: print("ERROR: Unable to register user: "******"command"] == "detach": results = AccountManager.detach_platform(data["platform_id"]) else: results = AccountManager.update_group(data["group_id"], data["updated_group"]) if results: return group_response_schema.dump({"success": results}) else: return {"success": False}, 409