def print_room(room_name): try: room = Room(room_name) allocations = room.allocations() print_pretty(" Allocations to room: " + room.name) print_pretty(Room.members(allocations)) except Exception as e: print_pretty(str(e))
def test_print_populated_room(self): self.clear_stores() office = Office("NDO") Dojo.add_room(office) fellow = Fellow("Xone", "Ndobile", "0856443334", "y") fellow.register() office.allocate_to(fellow) allocations = office.allocations() output = Room.members(allocations) self.assertEqual(output, " 0856443334, NDOBILE, XONE, FELLOW\n")
def test_print_existing_allocations_to_screen(self): self.clear_stores() office = Office("NDO2") Dojo.add_room(office) fellow = Fellow("Xone2", "Ndobile2", "0856443324", "y") fellow.register() office.allocate_to(fellow) allocations_ = Room.all_allocations() output = Room.members(allocations_, room_tag=True) expected_output = " NDO2-OFFICE, 0856443324, NDOBILE2, XONE2, FELLOW\n" self.assertEqual(output, expected_output)
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_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))