class CharacterAspectTest(unittest.TestCase):
    def setUp(self):
        self.c = Character("bob")

    def test_add(self):
        self.assertTrue(self.c.add_aspect("On Fire"), " Did not return correct on successful add")
        self.assertEqual("on fire",self.c.display_aspect(),"Did not add aspect properly")
        self.assertFalse(self.c.add_aspect("On Fire"), "Did not return false on duplicate")
        self.assertEqual("on fire", self.c.display_aspect(), "Did not deny duplicate properly")

    def test_remove(self):
        self.assertTrue(self.c.add_aspect("On Fire"), " Did not return correct on successful add")
        self.assertEqual("on fire", self.c.display_aspect(), "Did not add aspect properly")
        self.assertTrue(self.c.remove_aspect("On Fire"), " Did not return true on successful removal")
        self.assertEqual("", self.c.display_aspect(), "Did not remove aspect properly")

    def test_remove_non_case_sensitive(self):
        self.assertTrue(self.c.add_aspect("On Fire"), " Did not return correct on successful add")
        self.assertEqual("on fire", self.c.display_aspect(), "Did not add aspect properly")
        self.assertTrue(self.c.remove_aspect("on FiRe"), " Did not return true on successful removal")
        self.assertEqual("", self.c.display_aspect(), "Did not remove aspect properly")

    def test_remove_does_not_exist(self):
        self.assertFalse(self.c.remove_aspect("on FiRe"), " Did not return false on no removal")

    def test_multiple_aspects(self):
        aspects = ["on fire", "dying", "bleeding", "chronic fatigue", "glowing"]

        comma = 0
        for aspect in aspects:
            self.assertTrue(self.c.add_aspect(aspect), "Did not return correct on successful add")
            self.assertTrue(aspect in self.c.display_aspect(), "Did not add aspects into list")
            self.assertEqual(comma, self.c.display_aspect().count(','), "Did not add commas correctly")
            comma += 1
Example #2
0
class CharacterAllTest(unittest.TestCase):
    def setUp(self):
        self.c = Character("jane")

    def test_init(self):
        self.assertEqual(
            "jane\n"
            "Aspects: \n"
            "Skills: \n"
            "physical [1] [2]\n"
            "mental [1] [2]\n"
            "consequence [2] [4] [6]", str(self.c),
            "Did not properly initialise")

    def test_added(self):
        self.c.add_aspect("hiding")
        self.c.add_skill(1, "stealth")
        self.assertEqual(
            "jane\n"
            "Aspects: hiding\n"
            "Skills: | 1 stealth |\n"
            "physical [1] [2]\n"
            "mental [1] [2]\n"
            "consequence [2] [4] [6]", str(self.c), "Did not format correctly")

    def test_example_2(self):
        self.c.add_aspect("hiding")
        self.c.add_aspect("taken")
        self.c.add_skill(1, "stealth")
        self.c.add_skill(1, "heal")
        self.assertEqual(
            "jane\n"
            "Aspects: hiding, taken\n"
            "Skills: | 1 stealth | 1 heal |\n"
            "physical [1] [2]\n"
            "mental [1] [2]\n"
            "consequence [2] [4] [6]", str(self.c), "Did not format correctly")