Ejemplo n.º 1
0
class UnitTestRandom(unittest.TestCase):
    """Unit test cases."""

    def setUp(self):
        """Setup before each test case."""
        self.sut = SUT(['John'], ['Jane'], ['Doe'])
        self.assertEqual(self.sut.last_name, 'Doe')
        self.assertEqual(self.sut.first_name_female, 'Jane')
        self.assertEqual(self.sut.first_name_male, 'John')
        for entry in [self.sut.personality,
                      self.sut.demeanor,
                      self.sut.eyes,
                      self.sut.hair,
                      self.sut.skin,
                      self.sut.body_type,
                      self.sut.body_shape,
                      self.sut.primary_history,
                      self.sut.secondary_history]:
            self.assertEqual("None", entry)
        self.assertEqual(self.sut.primary_skill, ("None", "(+0) Mediocre"))
        self.assertEqual(self.sut.secondary_skill, ("None", "(+0) Mediocre"))
        self.assertEqual(self.sut.hobby_skill, ("None", "(+0) Mediocre"))
        self.assertEqual(self.sut.fear, ("None", "None"))

    def tearDown(self):
        """Cleans up after each test case."""

    def test_skill(self):
        result = self.sut.get_skill()
        self.assertTrue(result[0] in self.sut.SKILLS)
        self.assertTrue(result[1] in SKILLS_COMPETENCE)

    def test_get_npc(self):
        result = self.sut.get_markdown()
        for entry in ['Name',
            'Personality',
            'Demeanor',
            'Physical',
            'Body type',
            'Primary skills',
            'Secondary skills',
            'Hobby skills',
            'Major past event',
            'Minor past event']:
            self.assertTrue(entry in result)

    def test_get_new_data(self):
        old = self.sut.get_all_data
        self.sut.get_new_data()
        new = self.sut.get_all_data
        self.assertNotEqual(old, new)
Ejemplo n.º 2
0
def main():
    parser = optparse.OptionParser(version=__version__)
    parser.add_option(
        "-s",
        "--skills",
        dest="file_skills",
        default=None,
        help="A file containing a lists of skills [Optinal].",
        metavar="STR",
    )
    parser.add_option(
        "-n",
        "--names",
        dest="file_names",
        default=None,
        help="A file prefix to files containing a lists of names.",
        metavar="STR",
    )
    (options, args) = parser.parse_args(sys.argv)
    if options.file_names is None:
        sys.stderr.write("ERROR:  No name prefix, cannot continue.\n")
        sys.exit(1)
    here = os.path.dirname(__file__)
    if options.file_skills is not None:
        obj = NPC(
            os.path.join(here, "data", options.file_names + "_male_first_names.txt"),
            os.path.join(here, "data", options.file_names + "_female_first_names.txt"),
            os.path.join(here, "data", options.file_names + "_last_names.txt"),
            os.path.join(here, "data", options.file_skills + ".txt"),
        )
    else:
        obj = NPC(
            os.path.join(here, "data", options.file_names + "_male_first_names.txt"),
            os.path.join(here, "data", options.file_names + "_female_first_names.txt"),
            os.path.join(here, "data", options.file_names + "_last_names.txt"),
        )
    obj.get_new_data()
    print obj.get_markdown()