import unittest
from models.dojo import Dojo
from pathlib import Path
import os

class TestPrint(unittest.TestCase):
    def setUp(self):
        """ SetUp Dojo instance and populate test data"""
        self.instance=Dojo()
        offices=['Blue','Brown','Band']
        livingspaces=['Black','Bold','Blueberry']
        for livingspace in livingspaces:
            self.instance.create_room(livingspace,'livingspace')
        for office in offices:
            self.instance.create_room(office,'office')
        people = [['Joshua','Ondieki','fellow'],['Loice','Andia','fellow','Y'],['Morris','Kimani','fellow'],['Elizabeth','Mabishi','fellow','Y'],['Joy','Warugu','fellow','Y'],['Evans','Musomi','staff'],['Jackson','Saya','staff'],['James','Ndiga','staff'],['Annette','Kamau','staff']]

        for person in people:
            if len(person)==4:
                self.instance.add_person(person[0],person[1],person[2],person[3])
            else:
                self.instance.add_person(person[0],person[1],person[2])
        self.instance.print_allocations('test.txt')
        self.instance.print_unallocations('test1.txt')
        self.instance.all_people.append('Lost','Guy')  #add a person without getting allocations BUT should have:: LOST GUY FELLOW Y

    def tearDown(self):
        """Delete all files used during testing"""
        os.remove('test.txt')
        os.remove('test1.txt')

    def test_print_names_of_people_in_specific_room(self):
        people_in_Blue=self.instance.all_rooms['Blue'][1]
        query_with_room_name=self.instance.print_room('Blue')
        self.assertEqual(query_with_room_name,people_in_Blue)

    def test_print_allocations_without_file(self):
        get_allocations={k: v[1] for k, v in self.instance.all_rooms.items() if v[1]}  #dict with room name as key and members as value list
        print_allocations = self.instance.print_allocations()
        self.assertEqual(print_allocations,get_allocations)

    def test_print_allocations_with_file(self):
        test_file = Path("test.txt")
        self.assertTrue(test_file.is_file())

    def test_print_unallocations_without_file(self):

        print_unallocations = self.instance.print_unallocations()
        self.assertEqual(print_unallocations,['LOST GUY FELLOW Y'])

    def test_print_unallocations_with_file(self):
        test_file = Path("test1.txt")
        self.assertTrue(test_file.is_file())

@@ -1022,115 +1022,8 @@
 2%5D)%0A
-        self.instance.print_allocations('test.txt')%0A        self.instance.print_unallocations('test1.txt')%0A
     
@@ -1063,19 +1063,17 @@
 nd('Lost
-','
+ 
 Guy')  #
@@ -1149,24 +1149,26 @@
 ELLOW Y%0A%0A   
+ #
  def tearDow
@@ -1171,32 +1171,34 @@
 rDown(self):%0A   
+ #
      %22%22%22Delete a
@@ -1229,28 +1229,30 @@
 ting%22%22%22%0A    
+#
     
+ 
 os.remove('t
@@ -1260,24 +1260,26 @@
 st.txt')%0A   
+ #
      os.remo
@@ -1412,16 +1412,65 @@
 ue'%5D%5B1%5D%0A
+        people_in_Blue = %7B'Blue':people_in_Blue%7D%0A
         
@@ -1585,24 +1585,26 @@
 n_Blue)%0A%0A   
+ #
  def test_pr
@@ -1638,24 +1638,26 @@
 e(self):%0A   
+ #
      get_all
@@ -1782,28 +1782,30 @@
 ue list%0A    
+#
     
+ 
 print_alloca
@@ -1841,32 +1841,34 @@
 llocations()%0A   
+ #
      self.assert
@@ -1908,20 +1908,27 @@
 ations)%0A
+    #
 %0A   
+ #
  def tes
@@ -1959,32 +1959,88 @@
 _file(self):%0A   
+ #     self.instance.print_allocations('test.txt')%0A    #
      test_file =
@@ -2052,32 +2052,34 @@
 (%22test.txt%22)%0A   
+ #
      self.assert
@@ -2104,20 +2104,27 @@
 file())%0A
+    #
 %0A   
+ #
  def tes
@@ -2165,20 +2165,27 @@
 (self):%0A
+    #
 %0A   
+ #
      pri
@@ -2238,24 +2238,26 @@
 ations()%0A   
+ #
      self.as
@@ -2309,20 +2309,27 @@
 OW Y'%5D)%0A
+    #
 %0A   
+ #
  def tes
@@ -2366,24 +2366,83 @@
 e(self):%0A   
+ #     self.instance.print_unallocations('test1.txt')%0A    #
      test_fi
@@ -2463,24 +2463,26 @@
 t1.txt%22)%0A   
+ #
      self.as

Refactor tests