def api_newboard(): """ Initiates game and board Pre: valid json file with user specified rows, cols, mines, and userID Post: game generated by instantiating Executive and added to list Args: none Returns: True in JSON """ s = request.form.to_dict()['json_string'] json_acceptable_string = s.replace("'", "\"") d = json.loads(json_acceptable_string) rows = (int)(d['rows']) cols = (int)(d['cols']) mines = (int)(d['mines']) userID = (int)(d['userID']) # add new game to list of games try: newGame = Executive(rows, cols, mines, userID) except: return "INVALID_USER_INPUT" games.append(newGame) # POST with JSON return str(True)
def __init__(self, name=None, facility=None): Component.__init__(self, name, facility) Executive.__init__(self) # my name as seen by the shell import sys self.filename = sys.argv[0] # commandline arguments left over after parsing self.argv = [] self.unprocessedArguments = [] # the user input self.registry = None # the code generator self.weaver = None return
def testExecutive(self): executiveTest = Executive("12345","Richard","Barney","1990","03","25","2015-11-02","100000") executiveString = "12345\t\tRichard Barney\t\t1990-03-25\t2015-11-02\t$1923.08\t$384.62" self.assertEqual(executiveString, executiveTest.__str__())