class TestMainWindow(unittest.TestCase): def setUp(self): self.gui = MainWindow() self.char = Character.Character.Open(charfile) def test_load_misc(self): self.gui.LoadChar(self.char) self.assertEqual( self.gui.b.get_object('characterName').get_text(), 'Grognar') self.assertEqual( self.gui.b.get_object('playerName').get_text(), 'Grog') self.assertEqual( self.gui.b.get_object('profName').get_text(), 'Fighter') self.assertEqual(self.gui.b.get_object('charLevel').get_text(), '3') self.assertEqual( self.gui.b.get_object('experience').get_text(), '12345') def test_load_stats(self): self.gui.LoadChar(self.char) self.assertEqual( self.gui.b.get_object('statTable').get_property('n-columns'), 5) self.assertEqual( self.gui.b.get_object('statTable').get_property('n-rows'), 13) temp, bonus = self.gui.statWidgets['Constitution'] self.assertEqual(temp.get_text(), '100') self.assertEqual(bonus.get_text(), '15') temp, bonus = self.gui.statWidgets['Memory'] self.assertEqual(temp.get_text(), '50') self.assertEqual(bonus.get_text(), '0') temp, bonus = self.gui.statWidgets['Self Discipline'] self.assertEqual(temp.get_text(), '97') self.assertEqual(bonus.get_text(), '12') for row in self.gui.statStore: if row[TMH.StatListStore.col('Name')] == 'Agility': agRow = row elif row[TMH.StatListStore.col('Name')] == 'Presence': prRow = row self.assertEqual(agRow[TMH.StatListStore.col('Temporary')], 1) self.assertEqual(agRow[TMH.StatListStore.col('Bonus')], -15) self.assertEqual(prRow[TMH.StatListStore.col('Temporary')], 50) self.assertEqual(prRow[TMH.StatListStore.col('Bonus')], 0) agRow[TMH.StatListStore.col('obj')].Value = 100 self.gui.Update() self.assertEqual(agRow[TMH.StatListStore.col('Bonus')], 15) def test_load_skills(self): self.gui.LoadChar(self.char) for skIter in self.gui.skillStore.IterAll: skill, ranks, bonus = self.gui.skillStore.get( skIter, TMH.SkillTreeStore.col('obj'), TMH.SkillTreeStore.col('Ranks'), TMH.SkillTreeStore.col('Bonus')) if skill.Name == 'Elvish': self.assertEqual(ranks, 1) self.assertEqual(bonus, 9030) skill.Value = 15 self.gui.Update() skill, ranks, bonus = self.gui.skillStore.get( skIter, TMH.SkillTreeStore.col('obj'), TMH.SkillTreeStore.col('Ranks'), TMH.SkillTreeStore.col('Bonus')) self.assertEqual(ranks, 15) self.assertEqual(bonus, 9090) def test_load_items(self): self.gui.LoadChar(self.char) bookIter, earIter = list(self.gui.itemStore.IterAll) book = self.gui.itemStore.get(bookIter, TMH.ItemListStore.col('obj'))[0] ear = self.gui.itemStore.get(earIter, TMH.ItemListStore.col('obj'))[0] self.assertEqual( self.gui.itemStore.get(bookIter, TMH.ItemListStore.col('Name'))[0], 'Research Book') book.Name = 'Researchy Awesome Book' self.gui.Update() self.assertEqual( self.gui.itemStore.get(bookIter, TMH.ItemListStore.col('Name'))[0], 'Researchy Awesome Book') ear.Description = 'Maybe a bit transparent' self.gui.Update() self.assertEqual( self.gui.itemStore.get(earIter, TMH.ItemListStore.col('Description'))[0], 'Maybe a bit transparent')