def testCloneLyonnessePC(self): eAddrs=['*****@*****.**', '*****@*****.**'] testEntity = hydrauser.create_hydra_user(users.User(email=eAddrs[0])) origPub = hydrauser.create_hydra_user(users.User(email=eAddrs[1])) strength = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE, owner=origPub) ag = lyonnessespeed.get_lyonnessespeed( lyonnessespeed.LYONNESSESPEED_CREEPING, origPub) sp = lyonnessespeed.get_lyonnessespeed( lyonnessespeed.LYONNESSESPEED_DELIBERATE) dur = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE) testName = "Instance Name" testDesc = "I want to ride my bicycle" testLE = hydracontent.create_hydra_content(lyonnesselogentry.LyonnesseLogEntry, instanceName = testName, description = testDesc, owner = testEntity ) testLE.put() testHistory = hydracontent.create_hydra_content(lyonnessecreaturehistory.LyonnesseCreatureHistory, owner = testEntity, logEntries = [testLE.key()] ) testHistory.put() testContent = hydracontent.create_hydra_content( lyonnessepc.LyonnessePC, owner=origPub, originalPublisher=origPub, strength = strength, agility=ag, speed=sp, durability=dur, wounds = 1, fatigue = 2, maxhits = 12, history = testHistory, instanceName = testName ) testContent.put() result = testContent.clone( testEntity) self.assertIsNot( result, testContent) self.assertEqual(result.owner, testEntity) self.assertEqual(result.originalPublisher, origPub) self.assertEqual(result.instanceName, testName) self.assertIsInstance( result, lyonnessepc.LyonnessePC) self.assertEqual( result.strength, strength) self.assertEqual( result.agility, ag) self.assertEqual( result.speed, sp) self.assertEqual( result.durability, dur) self.assertEqual( result.maxhits, 12) self.assertEqual( result.wounds, 1) self.assertEqual( result.fatigue, 2) self.assertEqual( result.history, testHistory)
def testCreateLyonnesseMass(self): emailAddr='*****@*****.**' testEntity = hydrauser.create_hydra_user(users.User(email=emailAddr)) testContent = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_TINY, owner=testEntity ) result = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_TINY) self.assertIsNotNone(result) self.assertEqual( result, testContent) self.assertEqual( result.value, lyonnessemass.LYONNESSEMASS_TINY) self.assertEqual( result.valName, 'Tiny')
def testInsertLyonnesseArmor(self): emailAddr='*****@*****.**' testEntity = hydrauser.create_hydra_user(users.User(email=emailAddr)) testMass = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE, owner=testEntity) testProt = lyonnesseprotection.get_lyonnesseprotection(lyonnesseprotection.LYONESSEPROTECTION_MEDIUM, testEntity) testContent = hydracontent.create_hydra_content( lyonnessearmor.LyonnesseArmor, owner = testEntity, mass = testMass, protection = testProt, cover = "Full Body" ) testContent.put() result = hydracontent.load_hydra_content( testEntity) self.assertIsNotNone(result) result = db.get( testContent.key()) self.assertEqual( result.owner, testEntity) self.assertIsInstance( result, lyonnessearmor.LyonnesseArmor) self.assertEqual( result.cover, "Full Body") self.assertEqual( result.mass, testMass) self.assertEqual( result.protection, testProt)
def testEnumerateLyonnesseMass(self): emailAddr='*****@*****.**' testEntity = hydrauser.create_hydra_user(users.User(email=emailAddr)) result = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_NEGLIGIBLE, owner=testEntity) self.assertIsNotNone(result) self.assertEqual( result.value, lyonnessemass.LYONNESSEMASS_NEGLIGIBLE) self.assertEqual( result.valName, 'Negligible') result = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_TINY) self.assertIsNotNone(result) self.assertEqual( result.value, lyonnessemass.LYONNESSEMASS_TINY) self.assertEqual( result.valName, 'Tiny') result = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_SMALL) self.assertIsNotNone(result) self.assertEqual( result.value, lyonnessemass.LYONNESSEMASS_SMALL) self.assertEqual( result.valName, 'Small') result = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_AVERAGE) self.assertIsNotNone(result) self.assertEqual( result.value, lyonnessemass.LYONNESSEMASS_AVERAGE) self.assertEqual( result.valName, 'Average') result = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE) self.assertIsNotNone(result) self.assertEqual( result.value, lyonnessemass.LYONNESSEMASS_LARGE) self.assertEqual( result.valName, 'Large') result = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_HUGE) self.assertIsNotNone(result) self.assertEqual( result.value, lyonnessemass.LYONNESSEMASS_HUGE) self.assertEqual( result.valName, 'Huge')
def testCloneLyonnesseCreature(self): eAddrs=['*****@*****.**', '*****@*****.**'] testEntity = hydrauser.create_hydra_user(users.User(email=eAddrs[0])) origPub = hydrauser.create_hydra_user(users.User(email=eAddrs[1])) strength = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE, owner=origPub) ag = lyonnessespeed.get_lyonnessespeed( lyonnessespeed.LYONNESSESPEED_CREEPING, origPub) sp = lyonnessespeed.get_lyonnessespeed( lyonnessespeed.LYONNESSESPEED_DELIBERATE) dur = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE, origPub) testContent = hydracontent.create_hydra_content(lyonnessecreature.LyonnesseCreature, owner = origPub, originalPublisher = origPub, strength = strength, agility=ag, speed=sp, durability=dur, wounds = 1, fatigue = 2, maxhits = 12 ) testContent.put() result = testContent.clone( testEntity) self.assertIsNot( result, testContent) self.assertEqual(result.owner, testEntity) self.assertEqual(result.originalPublisher, origPub) self.assertIsInstance( result, lyonnessecreature.LyonnesseCreature) self.assertEqual( result.strength, strength) self.assertEqual( result.agility, ag) self.assertEqual( result.speed, sp) self.assertEqual( result.durability, dur) self.assertEqual( result.maxhits, 12) self.assertEqual( result.wounds, 1) self.assertEqual( result.fatigue, 2)
def testCloneLyonnesseArmor(self): eAddrs=['*****@*****.**', '*****@*****.**'] testEntity = hydrauser.create_hydra_user(users.User(email=eAddrs[0])) origPub = hydrauser.create_hydra_user(users.User(email=eAddrs[1])) testName = "testCloneLyonnesseArmor" testContent = hydracontent.create_hydra_content( lyonnessearmor.LyonnesseArmor, mass = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_TINY, owner=testEntity), cover = "Shield", owner=origPub, originalPublisher=origPub, instanceName = testName) testContent.put() result = testContent.clone( testEntity) self.assertIsNot( result, testContent) self.assertEqual(result.owner, testEntity) self.assertEqual(result.originalPublisher, origPub) self.assertEqual(result.instanceName, testName) self.assertIsInstance( result, lyonnessearmor.LyonnesseArmor) self.assertEqual( result.mass, lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_TINY))
def testInsertLyonnesseCreature(self): emailAddr='*****@*****.**' testEntity = hydrauser.create_hydra_user(users.User(email=emailAddr)) strength = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE, owner=testEntity) ag = lyonnessespeed.get_lyonnessespeed( lyonnessespeed.LYONNESSESPEED_CREEPING, testEntity) sp = lyonnessespeed.get_lyonnessespeed( lyonnessespeed.LYONNESSESPEED_DELIBERATE) dur = lyonnessemass.get_lyonnessemass(lyonnessemass.LYONNESSEMASS_LARGE) testContent = hydracontent.create_hydra_content(lyonnessecreature.LyonnesseCreature, owner = testEntity, strength = strength, agility=ag, speed=sp, durability=dur, wounds = 1, fatigue = 2, maxhits = 12 ) testContent.put() result = hydracontent.load_hydra_content( testEntity) self.assertIsNotNone(result) result = db.get( testContent.key()) self.assertEqual( result.owner, testEntity) self.assertIsInstance( result, lyonnessecreature.LyonnesseCreature) self.assertEqual( result.strength, strength) self.assertEqual( result.agility, ag) self.assertEqual( result.speed, sp) self.assertEqual( result.durability, dur) self.assertEqual( result.maxhits, 12) self.assertEqual( result.wounds, 1) self.assertEqual( result.fatigue, 2)
def get(self): currentUser = users.get_current_user() if not currentUser: # logged out, log the user back in url = users.create_login_url(self.request.uri) self.redirect(url) else: action = self.request.get("action") if action and action == 'new': # creating a new item hu = hydrauser.get_hydra_user(currentUser.nickname(), True) item = hydracontent.create_hydra_content(lyonnesseitem.LyonnesseItem, owner=hu, originalPublisher=hu ) template = jinja_environment.get_template('lyonnesseview/itemdetail.html') else: item = None template = jinja_environment.get_template('lyonnesseview/itemchoice.html') template_values = { 'logoutURL': users.create_logout_url(self.request.uri), 'currentUserID': currentUser.nickname(), 'massRBG0': lyonnessemass.get_lyonnessemass( lyonnessemass.LYONNESSEMASS_NEGLIGIBLE).valName, 'massRBG1': lyonnessemass.get_lyonnessemass( lyonnessemass.LYONNESSEMASS_TINY).valName, 'massRBG2': lyonnessemass.get_lyonnessemass( lyonnessemass.LYONNESSEMASS_SMALL).valName, 'massRBG3': lyonnessemass.get_lyonnessemass( lyonnessemass.LYONNESSEMASS_AVERAGE).valName, 'massRBG4': lyonnessemass.get_lyonnessemass( lyonnessemass.LYONNESSEMASS_LARGE).valName, 'massRBG5': lyonnessemass.get_lyonnessemass( lyonnessemass.LYONNESSEMASS_HUGE).valName } if item: template_values['item'] = item self.response.out.write(template.render(template_values))