def test_culture_making(self): proto = Parser.cultureFile(cultureFile)[1] proto.char = Parser.characterFile(charFile) self.assertEqual(len(proto.Culture.ChildValues), 6) proto.Select(1, 0) proto.Select(2, 0) proto.Select(3, 0) proto.Select(13, 0) culture = proto.Culture self.assertEqual(len(culture.ChildValues), 10)
def test_culture_making(self): proto = Parser.cultureFile(cultureFile)[1] proto.char = Parser.characterFile(charFile) self.assertEqual(len(proto.Culture.ChildValues),6) proto.Select(1,0) proto.Select(2,0) proto.Select(3,0) proto.Select(13,0) culture = proto.Culture self.assertEqual(len(culture.ChildValues),10)
def run_test3(self): print 'building new parser/portfolio from test.algo' recipeParser = Parser('test.algo') self.controller.portfolio = recipeParser.build_portfolio() for recipe in self.controller.portfolio.recipes.values(): self.controller.graphed.append(recipe.name) self.controller.table.addRecipe(recipe.name) # run the controller evaluating in a loop print "Test called" for x in xrange(1,20): self.controller.run(x) # every other one should be true (xing fingers)
def test_load(path): parser = Parser(path) portfolio = parser.build_portfolio() assert(portfolio) assert(len(portfolio.recipes)==1) assert(len(portfolio.recipes[0].rows)==1) print "portfolio loaded" print portfolio.run(2) # 99 print portfolio.run(2) # 99 print portfolio.run(1) # 99 print portfolio.run(2) # 98 print portfolio.run(2) # 98 print portfolio.get_performance()
def openPortfolio(self): #bring up a file dialog so they can open it path = QFileDialog.getOpenFileName(self, dir="/home/dylan/mock_algo/", filter="*.torg")[0] if path == '': return self.portfolioPath = path parser = Parser(self.portfolioPath) self.controller.portfolio = parser.build_portfolio() #reset the rows and add all the new recipes self.rows = {} for key, recipe in self.controller.portfolio.recipes.items(): self.addRecipe(recipe.name)
def test_parsing_all(self): protos = Parser.cultureFile(cultureFile) self.assertEqual(protos[0].Name, 'Cosmopolitan') self.assertEqual(protos[0].options[7], (['Survival', 'Region, Own'], 1, True)) self.assertEqual(protos[1].Name, 'Rural') self.assertEqual(protos[1].options[8], (['Animal Handling', 0], 1, True))
def chooseFile(self): fileName = QFileDialog.getOpenFileName(self, dir="/home/dylan/mock_algo/", filter="*.algo") if fileName == '': return #add some method to send file name to backend here!! print fileName """ADD FUNCTION HERE...LET IT RETURN TRUE IF VALID FILE""" parser = Parser(None) # don't need a path to recipe recipe = None try: recipe = parser.parse_recipe(str(fileName[0])) except: msgBox = QMessageBox(QMessageBox.Icon.Critical, "Error", ""); msgBox.setText("Unable to open file.") msgBox.exec_() return if recipe: self.table.addRecipe(recipe.name,)
def test_parsing_all(self): protos = Parser.cultureFile(cultureFile) self.assertEqual(protos[0].Name,'Cosmopolitan') self.assertEqual(protos[0].options[7],(['Survival','Region, Own'],1,True)) self.assertEqual(protos[1].Name,'Rural') self.assertEqual(protos[1].options[8],(['Animal Handling',0],1,True))
def MakeTalentList(self): self._talents = Parser.talentFile(resource('tables','Talents.txt')) talentBox = self['talentBox'] combobox_boilerplate(talentBox) for talent in self._talents: talentBox.append_text(talent.Name)
def MakeRaceList(self): self._races = Parser.raceFile(resource('tables','Races.txt')) raceBox = self['raceBox'] combobox_boilerplate(raceBox) for race in self._races: raceBox.append_text(race.Name)
def MakeCultureList(self): self._cultures = Parser.cultureFile(resource('tables','Cultures.txt')) cultureBox = self['cultureBox'] combobox_boilerplate(cultureBox) for proto in self._cultures: cultureBox.append_text(proto.Name)
def MakeProfessionList(self): self._professions = Parser.professionFile(resource('tables','Professions.txt')) profBox = self['profBox'] combobox_boilerplate(profBox) for prof in self._professions: profBox.append_text(prof.Name)