def stunt_create_test(self): from tof.models.sotc.crunch import Stunt try: with transaction.manager: name = "Stupendous Stunt" model = Stunt(name=name) DBSession.add(model) with transaction.manager: model = DBSession.query(Stunt).filter(Stunt.name==name).one() self.assertEqual(model.name, name) finally: with transaction.manager: DBSession.delete(model)
def character_create_test(self): from tof.models.character import Character try: with transaction.manager: model = Character(name='Mack Silver, Entrepreneurial Pilot', played_by="John") DBSession.add(model) with transaction.manager: model = DBSession.query(Character).filter(Character.name=="Mack Silver, Entrepreneurial Pilot").one() self.assertEqual(model.name, "Mack Silver, Entrepreneurial Pilot") self.assertEqual(model.played_by, "John") finally: with transaction.manager: DBSession.delete(model)
def aspect_create_test(self): from tof.models.sotc.crunch import Aspect try: with transaction.manager: name = "Astounding Aspect" model = Aspect(name=name) DBSession.add(model) with transaction.manager: model = DBSession.query(Aspect).filter(Aspect.name==name).one() self.assertEqual(model.name, name) finally: with transaction.manager: DBSession.delete(model)
def character_create_test(self): from tof.models.sotc.character import SotCCharacter as Character from tof.models.sotc.crunch import Skill, Aspect, Stunt, Ladder try: with transaction.manager: aspects = [Aspect(name="\"Lucy\", the Century Clipper"), Aspect(name="Fly by Night")] skills = [Skill(name="Contacting", level=Ladder.superb), Skill(name="Pilot", level=Ladder.great)] stunts = [Stunt(name="Walk the Walk"), Stunt(name="Lucy (Personal Gadget)")] model = Character(name='Mack Silver, Entrepreneurial Pilot', played_by="John", skills=skills, aspects=aspects, stunts=stunts, fate_points=11, refresh_rate=11) DBSession.add(model) with transaction.manager: model = DBSession.query(Character).filter(Character.name=="Mack Silver, Entrepreneurial Pilot").one() self.assertEqual(model.name, "Mack Silver, Entrepreneurial Pilot") self.assertEqual(model.played_by, "John") self.assertEqual(model.fate_points, 11) self.assertEqual(model.refresh_rate, 11) self.assertItemsEqual([m.name for m in model.aspects], [a.name for a in aspects]) self.assertItemsEqual([{m.name: m.level} for m in model.skills], [{m.name: m.level.value} for m in skills]) self.assertItemsEqual([m.name for m in model.stunts], [a.name for a in stunts]) finally: with transaction.manager: c = DBSession.query(Character).filter(Character.name=="Mack Silver, Entrepreneurial Pilot").one() DBSession.delete(c) for skill in skills: s = DBSession.query(Skill).filter(Skill.name==skill.name).one() DBSession.delete(s) for aspect in aspects: s = DBSession.query(Aspect).filter(Aspect.name==aspect.name).one() DBSession.delete(s) for stunt in stunts: s = DBSession.query(Stunt).filter(Stunt.name==stunt.name).one() DBSession.delete(s)
def skill_create_test(self): from tof.models.sotc.crunch import Skill, Ladder try: with transaction.manager: name = "Superlative Skill" model = Skill(name=name, level=Ladder.superb) DBSession.add(model) with transaction.manager: model = DBSession.query(Skill).filter(Skill.name==name).one() self.assertEqual(model.name, name) self.assertEqual(model.level, Ladder.superb.value) finally: with transaction.manager: DBSession.delete(model)