class TestMafiaOrganizationMemberToFreedomCase3MultiLevelsKillLevel2(TestCase):
    def setUp(self):
        # Given
        self.big_boss = Gangster('Big Boss', 21)
        self.g1 = Gangster('Gangster', 20, 'Location Gangster')
        self.g2 = Gangster('Gangster 2', 30, 'Location Gangster 2')
        self.g3 = Gangster('Gangster 3', 32, 'Location Gangster 3')

        self.mog = MafiaOrganization(self.big_boss)
        self.mog.add_under(self.big_boss, self.g1)
        self.mog.add_under(self.g1, self.g2)
        self.mog.add_under(self.g1, self.g3)

        self.mog.send_member_to_jail('Gangster')

        # When
        self.mog.set_member_to_freedom('Gangster')

    def test_set_member_to_freedom_is_in_organization(self):
        self.assertIsInstance(self.mog.find_by_name('Gangster'), Gangster)

    def test_set_member_to_freedom_is_found_by_is_member_of_organization(self):
        self.assertTrue(self.mog.is_member_of_organization('Gangster'))

    def test_set_member_to_freedom_subordinate_is_still_in_organization(self):
        self.assertIsInstance(self.mog.find_by_name('Gangster 2'), Gangster)
        self.assertIsInstance(self.mog.find_by_name('Gangster 3'), Gangster)

    def test_set_member_to_freedom_previous_subordinate_returns_to_the_previous_boss(self):
        self.assertEquals(self.g3.get_boss(), self.g1)
        self.assertEquals(self.g2.get_boss(), self.g1)

    def test_correct_organization_count(self):
        self.assertEquals(self.mog.members_count(), 4)
class TestMafiaOrganizationSetMemberToFreedom(TestCase):
    def setUp(self):
        self.big_boss = Gangster('Big Boss', 21)

        self.g1 = Gangster('Gangster', 20)
        self.g2 = Gangster('Gangster 2', 20, 'Location 2')

        self.mog = MafiaOrganization(self.big_boss)
        self.mog.add_under(self.big_boss, self.g1)
        self.mog.add_under(self.g1, self.g2)

        self.mog.send_member_to_jail('Gangster')

    def test_set_member_to_freedom_on_unknown_gangster_returns_false(self):
        self.assertFalse(self.mog.set_member_to_freedom('Unknown Gangster'))

    def test_set_member_to_freedom_on_known_gangster_returns_true(self):
        self.assertTrue(self.mog.set_member_to_freedom('Gangster'))

    def test_set_member_to_freedom_sets_freestatus(self):
        self.mog.set_member_to_freedom('Gangster')

        self.assertEquals(self.g1.status, GangsterStatus.FREE)

    def test_set_member_to_freedom_restores_all_subordinates(self):
        self.mog.set_member_to_freedom('Gangster')

        self.assertEquals(self.g1.subordinates_count(), 1)