def test_print_existing_allocations_to_default_file(self): self.clear_stores() office = Office("ND2") Dojo.add_room(office) fellow = Fellow("Xne2", "Ndoile2", "0868443324", "y") fellow.register() office.allocate_to(fellow) allocations_ = Room.all_allocations() expected_output = Room.members(allocations_, room_tag=True) Room.to_file(expected_output) path = "output/" f = open(path + "File.txt", "r") output = f.read() #"NDO2-Office, 0856443324, NDOBILE2, XONE2, FELLOW" f.close() self.assertEqual(expected_output, output)
def test_print_existing_allocations_to_specific_file(self): self.clear_stores() office = Office("ND88") Dojo.add_room(office) fellow = Fellow("Xne88", "Ndoile88", "086800000", "y") fellow.register() office.allocate_to(fellow) allocations_ = Room.all_allocations() expected_output = Room.members(allocations_, room_tag=True) file_name = office.name + "-Allocations" Room.to_file(expected_output, file_name) path = "output/" f = open(path + file_name + ".txt", "r") output = f.read() f.close() self.assertEqual(expected_output, output)
def print_unallocated(out, file_name): try: output = Room.all_unallocated_persons() if len(output) > 0: if out is True: if file_name is not None: Room.to_file(output, file_name) print_pretty( " A list of unallocated persons can be found in the output directory under the file %s.txt" % file_name) else: Room.to_file(output) print_pretty( " A list of unallocated persons can be found in the output directory under the file File.txt" ) else: print_pretty(output) else: print_pretty(" There are no unallocated persons to show") except Exception as e: print_pretty(str(e))
def print_allocations(out, file_name): try: allocations = Room.all_allocations() output = Room.members(allocations, room_tag=True) if len(output) > 0: if out is True: if file_name is not None: Room.to_file(output, file_name) print_pretty( " A list of allocated persons can be found in the output directory under the file %s.txt" % file_name) else: Room.to_file(output) print_pretty( " A list of allocated persons can be found in the output directory under the file File.txt" ) else: print_pretty(output) else: print_pretty(" There are no allocations to show") except Exception as e: print_pretty(str(e))