def test_creation(self): """ """ name = Name(self.redis, 'human') self.assertEqual('Drucilla LaSalvae', str(name.fullname)) self.assertEqual('Drucilla', str(name.shortname)) self.assertEqual('LaSalvae', str(name.formalname)) self.assertEqual('Drucilla Lasalvae', str(name))
def test_staticadditional_title(self): """ """ name = Name(self.redis, 'human', { 'title': 'Poobah', "first_pre": "Blah" }) self.assertEqual('Poobah Blahcilla LaSalvae', name.fullname) self.assertEqual('Poobah Blahcilla Lasalvae', str(name))
def test_static_nochancese(self): """ """ self.redis.set('humanname_first_pre_chance', '0') self.redis.set('humanname_first_root_chance', '0') self.redis.set('humanname_first_post_chance', '0') self.redis.set('humanname_last_pre_chance', '0') self.redis.set('humanname_last_root_chance', '0') self.redis.set('humanname_last_post_chance', '0') name = Name(self.redis, 'human', { 'title': 'Poobah', "first_pre": "Blah" }) self.assertEqual('Poobah Blah', str(name))
def test_business(self): """ """ name = Name(self.redis, 'business', {'businesstype': 'Butcher'}) self.assertEqual('business', str(name.namesource)) print "business: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertIn(' {{params.noun}} ', str(name.fullname_template)) self.assertIn('{{params.adjective}} ', str(name.fullname_template)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_organization(self): """ """ leader = NPC(self.redis) name = Name(self.redis, 'organization', {'leader': leader}) self.assertEqual('organization', str(name.namesource)) print "organization: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertEqual(str(name.fullname), str(name.formalname)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_dungeon(self): """ """ name = Name(self.redis, 'dungeon') self.assertEqual('dungeon', str(name.namesource)) print "dungeon: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertIn('{{params.place}} ', str(name.fullname_template)) self.assertEqual(str(name.fullname), str(name.formalname)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_races(self): """ """ for race in self.redis.lrange('npc_race', 0, -1): name = Name(self.redis, race, {'title': 'Mr.'}) self.assertEqual(race, str(name.namesource)) print "%s: %s | %s | %s" % (race, name.fullname, name.shortname, name.formalname) self.assertIn('{{params.title}} ', str(name.fullname_template)) self.assertIn(' {{params.trailer}}', str(name.fullname_template)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_continent(self): """ """ name = Name(self.redis, 'continent', {'continenttype': 'Butcher'}) self.assertEqual('continent', str(name.namesource)) print "continent: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertIn('{{params.title}} ', str(name.fullname_template)) self.assertIn(' {{params.pre}}', str(name.fullname_template)) self.assertIn('{{params.root}}', str(name.fullname_template)) self.assertIn('{{params.post}}', str(name.fullname_template)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_street(self): """ """ name = Name(self.redis, 'street') self.assertEqual('street', str(name.namesource)) print "street: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertIn('{{params.title}} ', str(name.fullname_template)) self.assertIn(' {{params.root}} ', str(name.fullname_template)) self.assertIn(' {{params.trailer}}', str(name.fullname_template)) self.assertIn('{{params.root}}', str(name.shortname_template)) self.assertEqual(str(name.fullname), str(name.formalname)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_star(self): """ """ name = Name(self.redis, 'star') self.assertEqual('star', str(name.namesource)) print "star: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertIn('{{params.pre}}', str(name.fullname_template)) self.assertIn('{{params.root}}', str(name.fullname_template)) self.assertIn('{{params.post}}', str(name.fullname_template)) self.assertEqual(str(name.fullname), str(name.shortname)) self.assertEqual(str(name.fullname), str(name.formalname)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_region(self): """ """ name = Name(self.redis, 'region') self.assertEqual('region', str(name.namesource)) print "region: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertIn('{{params.title}} ', str(name.fullname_template)) self.assertIn(' {{params.pre}}', str(name.fullname_template)) self.assertIn('{{params.root}}', str(name.fullname_template)) self.assertIn('{{params.post}} ', str(name.fullname_template)) self.assertIn(' {{params.trailer}}', str(name.fullname_template)) self.assertEqual(str(name.fullname), str(name.shortname)) self.assertEqual(str(name.fullname), str(name.formalname)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_country(self): """ """ name = Name(self.redis, 'country') self.assertEqual('country', str(name.namesource)) print "country: %s | %s | %s" % (name.fullname, name.shortname, name.formalname) self.assertIn('{{params.title}} ', str(name.fullname_template)) self.assertIn(' {{params.pre}}', str(name.fullname_template)) self.assertIn('{{params.root}}', str(name.fullname_template)) self.assertIn('{{params.post}}', str(name.fullname_template)) self.assertEqual(str(name.fullname), str(name.shortname)) self.assertEqual(str(name.fullname), str(name.formalname)) self.assertNotIn('{{', str(name.fullname)) self.assertNotIn('}}', str(name.fullname)) self.assertNotIn('params', str(name.fullname)) self.assertNotIn('{{', str(name.shortname)) self.assertNotIn('}}', str(name.shortname)) self.assertNotIn('params', str(name.shortname)) self.assertNotIn('{{', str(name.formalname)) self.assertNotIn('}}', str(name.formalname)) self.assertNotIn('params', str(name.formalname))
def test_additional_title(self): """ """ self.redis.lpush('humanname_title', 'Lord') name = Name(self.redis, 'human') self.assertEqual('Lord Drucilla LaSalvae', name.fullname)
def test_missing_fullname_template(self): self.redis.delete('humanname_fullname_template') with self.assertRaisesRegexp(LookupError, "fullname_template not found for human"): name = Name(self.redis, 'human')