import os
import sys
import unittest
from os import path
from dojo import Dojo
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))


class TestsCasesRoom(unittest.TestCase):
    """Tests all the functionality of create_room method.
    """
    def setUp(self):
        """Creates an instance of the class dojo and passes instance to all tests
         in the test case.
        """
        self.dojo = Dojo()
        self.office1 = self.dojo.create_room('Valhalla', 'office')
        self.room1 = self.dojo.create_room('Nexus', 'livingspace')
        self.office = self.dojo.offices[0].room_type
        self.office_name = self.dojo.offices[0].room_name
        self.offices = self.dojo.offices
        self.rooms = self.dojo.livingrooms

    def test_office_created_successfully(self):
        initial_room_count = len(self.dojo.offices)
        self.office2 = self.dojo.create_room('Hogwarts', 'office')
        new_room_count = len(self.dojo.offices)
        self.assertEqual(new_room_count - initial_room_count, 1)

    def test_living_rooms_created_successfully(self):
        initial_room_count = len(self.rooms)
        self.living = self.dojo.create_room('Python', 'livingspace')
        new_room_count = len(self.rooms)
        self.assertEqual(new_room_count - initial_room_count, 1)

    def test_office_creation_repeated(self):
        initial_room_count = len(self.rooms)
        self.office1 = self.dojo.create_room('Valhalla', 'office')
        new_room_count = len(self.offices)
        self.assertEqual(new_room_count - initial_room_count, 0)

    def test_livingspace_creation_repeated(self):
        initial_room_count = len(self.rooms)
        self.room2 = self.dojo.create_room('Nexus', 'livingspace')
        new_room_count = len(self.rooms)
        self.assertEqual(new_room_count - initial_room_count, 0)


class AddPersonTestCases(unittest.TestCase):
    """Tests all the functionality of create_room method.
    """
    def setUp(self):
        """Create an instance of  the class dojo and pass it all tests in test case
        """
        self.dojo = Dojo()
        self.fellow1 = self.dojo.add_person('Salat', 'Abdala', 'Fellow')
        self.staff1 = self.dojo.add_person('Naima', 'Hussein', 'Staff')
        self.office1 = self.dojo.create_room('Argon', 'office')
        self.room1 = self.dojo.create_room('west', 'livingspace')
        self.fellow_name = self.dojo.fellows[0].fname
        self.staff_name = self.dojo.staff[0].fname

    def test_fellow_added_successfully(self):
        initial_fellow_count = len(self.dojo.fellows)
        self.fellow2 = self.dojo.add_person('Burei', 'Dollar', 'Fellow')
        new_fellow_count = len(self.dojo.fellows)
        self.assertEqual(new_fellow_count - initial_fellow_count, 1)

    def test_fellow_wants_room_added_successfully(self):
        initial_fellow_count = len(self.dojo.fellows)
        self.fellow3 = self.dojo.add_person('Jackie', 'Macharia', 'Fellow', 'Y')
        new_fellow_count = len(self.dojo.fellows)
        self.assertEqual(new_fellow_count - initial_fellow_count, 1)

    def test_staff_added_successfully(self):
        initial_staff_count = len(self.dojo.staff)
        self.staff2 = self.dojo.add_person('Eva', 'Njeri', 'Staff')
        new_staff_count = len(self.dojo.staff)
        self.assertEqual(new_staff_count - initial_staff_count, 1)

    def test_staff_repetition(self):
        initial_staff_count = len(self.dojo.staff)
        self.staff2 = self.dojo.add_person('Eva', 'Njeri', 'Staff')
        new_staff_count = len(self.dojo.staff)
        self.assertEqual(new_staff_count - initial_staff_count, 0)

    def test_add_fellow_repetition(self):
        initial_fellow_count = len(self.dojo.fellows)
        self.fellow2 = self.dojo.add_person('Burei', 'Dollar', 'Fellow')
        new_fellow_count = len(self.dojo.fellows)
        self.assertEqual(new_fellow_count - initial_fellow_count, 0)



if __name__ == "__main__":
    unittest.main()

@@ -2474,16 +2474,82 @@
 0%5D.fname
+%0A        self.room_capacity = self.dojo.all_rooms%5B0%5D.room_capacity
 %0A%0A    de
@@ -3986,16 +3986,836 @@
 nt, 0)%0A%0A
+    def test_fellow_room_allocation_successful(self):%0A        # if a fellow gets allocated the the room capacity should decrease by 1%0A        initial_room_capacity = self.dojo.all_rooms%5B0%5D.room_capacity%0A        self.fellow2 = self.dojo.add_person('Burei', 'Dollar', 'Fellow')%0A        new_room_capacity = self.dojo.all_rooms%5B0%5D.room_capacity%0A        self.assertTrue((initial_room_capacity - new_room_capacity), 1)%0A%0A    def test_staff_room_allocation_successful(self):%0A        # if a staff member gets a room , room capacity should decrease by 1%0A        initial_room_capacity = self.dojo.all_rooms%5B0%5D.room_capacity%0A        self.staff2 = self.dojo.add_person('Naomi', 'Dollar', 'Staff')%0A        new_room_capacity = self.dojo.all_rooms%5B0%5D.room_capacity%0A        self.assertTrue((initial_room_capacity - new_room_capacity), 1)
 %0A%0Aif __n

Add tests for successful room allocation