class AmityTestLoadPeople(unittest.TestCase): """ This class tests all cases associated with load_people function """ def setUp(self): "Setup for class initializations" self.amity = Amity() def test_load_people_handles_invalid_path(self): "Tests if a file path is valid" wrong_path = '/wrongfilepath.txt' status = self.amity.load_people(wrong_path) self.assertEqual('Invalid filepath.', status) def test_if_load_people_filepath_loads_file(self): "Tests if file is loaded" empty_filepath = 'files/empty_file.txt' status = self.amity.load_people(empty_filepath) self.assertEqual('The file has no contents', status)
class TestAmity(unittest.TestCase): """ Test amity """ def setUp(self): self.amity = Amity() self.offices = self.amity.offices self.living_spaces = self.amity.living_spaces self.fellows = self.amity.fellows self.staff = self.amity.staff self.new_offices = self.amity.create_room("O", "Occulus", "Narnia") self.new_living_space = self.amity.create_room("L", 'mombasa') self.new_fellow = self.amity.add_person("hum", "musonye", "fellow", "Y") self.new_staff = self.amity.add_person("hum", "musonye", "staff", "N") self.unallocated_fellows = self.amity.unallocated_fellow self.unallocated_staff = self.amity.unallocated_staff def test_create_living_space(self): """ Tests whether a livingspace(room) is created. """ initial_room_count = len(self.living_spaces) self.amity.create_room("L", 'php') new_room_count = len(self.living_spaces) self.assertEqual(new_room_count, initial_room_count + 1) def test_create_office(self): """ Tests whether an office(room) is created. """ initial_room_count = len(self.offices) self.amity.create_room("O", "Camelot") new_room_count = len(self.offices) self.assertEqual(new_room_count, initial_room_count + 1) def test_create_multiple_rooms(self): """ Tests whether multiple rooms can be created. """ initial_room_count = len(self.living_spaces) self.amity.create_room("L", "Scalar", "Laravel") new_room_count = len(self.living_spaces) self.assertEqual(new_room_count, initial_room_count + 2) def test_room_already_exists(self): """ Test behaiviour of create room, when you create an already existing room """ self.new_living_space msg = self.amity.create_room("L", "mombasa") self.assertEqual("Room Already Exists!", msg) def test_invalid_room_type(self): """ Tests whether message is return when invalid room type param is passed""" new_room = self.amity.create_room("S", "Laravel") self.assertEqual(new_room, "Inavlid Room Type!") def test_vacant_rooms_returned(self): """ Tests whether rooms that have remaining slots are returned. """ new_room = Office('mombasa') self.amity.check_vacant_rooms() vacant_status = new_room.is_full() self.assertFalse(vacant_status) def test_is_full_returns_true(self): """ Tests whether the system knows when a room is fully occupied. """ new_room = Office('mombasa') new_room.occupants.append(136648) new_room.occupants.append(136650) new_room.occupants.append(136651) new_room.occupants.append(136652) new_room.occupants.append(136653) new_room.occupants.append(136654) vacant_status = new_room.is_full() self.assertTrue(vacant_status) def test_is_full_returns_false(self): """ Tests whether the system knows when a room is not fully occupied. """ new_room = Office('mombasa') new_room.occupants.append(136648) new_room.occupants.append(136650) new_room.occupants.append(136651) vacant_status = new_room.is_full() self.assertFalse(vacant_status) def test_add_fellow(self): """ Tests if a fellow is added successfully added. """ new_fellow = self.new_fellow self.assertEqual("Person Created Successfully!", new_fellow) def test_add_staff(self): """ Tests if a staff is added successfully added """ new_staff = self.new_staff self.assertEqual("Person Created Successfully!", new_staff) def test_new_fellow_in_unallocated(self): """ Tests whether a newly created fellow is saved to the unallocated list. """ unallocated_status = True if len(self.unallocated_fellows) > 0 else False self.assertTrue(unallocated_status) def test_new_staff_in_unallocated(self): """ Tests whether a newly created staff is saved to the unallocated list. """ unallocated_status = True if len(self.unallocated_staff) > 0 else False self.assertTrue(unallocated_status) def test_allocate_staff(self): """ Tests whether a new staff member is allocated an office. """ staff = self.staff[-1] self.amity.allocate_person(str(staff.employee_id)) unallocated_length = len(self.unallocated_staff) self.assertEqual(0, unallocated_length) def test_allocate_fellow(self): """ Tests whether a new fellow is allocated an office and livingspace. """ fellow = self.fellows[-1] self.amity.allocate_person(str(fellow.employee_id)) unallocated_length = len(self.unallocated_fellows) self.assertEqual(0, unallocated_length) def test_if_person_not_found(self): """ Tests whether a non-existent person can be allocated a room. """ non_existent_person = 1000001 allocated_status = self.amity.allocate_person(str(non_existent_person)) self.assertEqual("Person not found!", allocated_status) def test_if_livingspaces_not_found(self): """ Test whether allocate_person works when no living_spaces are created. """ fellow = self.fellows[-1] self.amity.living_spaces = [] allocated_msg = self.amity.allocate_person(str(fellow.employee_id)) self.assertIn("LivingSpace not available!", allocated_msg) def test_if_offices_not_found(self): """ Test whether allocate_person works when no offices are created. """ fellow = self.fellows[-1] self.amity.offices = [] allocated_msg = self.amity.allocate_person(str(fellow.employee_id)) self.assertIn("Office not available!", allocated_msg) def test_when_staff_wants_lspace(self): """ Tests whether the system returns an error message when Staff wants_accomodation = Y """ self.amity.add_person("alexis", "sanchez", "staff", "Y") staff = self.staff[-1] allocated_msg = self.amity.allocate_person(str(staff.employee_id)) self.assertIn("Cannot assign LivingSpace to staff!", allocated_msg) def test_reallocate_if_person_not_found(self): """ Tests whether a non-existent person can be reallocated to a room. """ non_existent_person = 1000001 allocated_status = self.amity.reallocate_person(str(non_existent_person), 'mombasa') self.assertEqual("Person not found", allocated_status) def test_if_new_room_name_exists(self): """ Test whether reallocate_person finds new_room_name. """ fellow = self.fellows[-1] self.amity.allocate_person(str(fellow.employee_id)) reallocated_status = self.amity.reallocate_person(str(fellow.employee_id), 'mogadishu') self.assertEqual("Room does not Exist!", reallocated_status) def test_reallocate_lspace(self): """ Test whether a person can be reallocated from one room to another. """ fellow = self.fellows[-1] self.amity.allocate_person(str(fellow.employee_id)) self.amity.create_room("L", 'kilifi') reallocated_status = self.amity.reallocate_person(str(fellow.employee_id), 'kilifi') self.assertIn("Successfully Reallocated", reallocated_status) def test_reallocate_office(self): """ Test whether a person can be reallocated from one room to another. """ fellow = self.fellows[-1] self.amity.allocate_person(str(fellow.employee_id)) self.amity.create_room("O", 'kilaguni') reallocated_status = self.amity.reallocate_person(str(fellow.employee_id), 'kilaguni') self.assertIn("Successfully Reallocated", reallocated_status) def test_staff_reallocated_lspace(self): """ Test that error message is returned when staff is reallocated to \ LivingSpace """ staff = self.staff[-1] self.amity.allocate_person(str(staff.employee_id)) reallocated_status = self.amity.reallocate_person(str(staff.employee_id), 'mombasa') self.assertIn("Cannot reallocate staff to livingspace!", reallocated_status) def test_load_people(self): """ Test whether load_people adds people to room from a text file. """ self.amity.fellows = [] self.amity.load_people("people") self.assertTrue(self.amity.fellows) def test_load_people_from_non_existent_file(self): """ Tests whether people can be loaded from a non-existent file. """ load_people = self.amity.load_people("persons") self.assertEqual("File: persons, Not Found!", load_people) def test_allocations_outputs_file(self): """ Tests whether allocations can be printed on file: new_allocations. """ staff = self.staff[-1] self.amity.allocate_person(str(staff.employee_id)) self.amity.print_allocations("new_allocations") file_path = os.path.abspath("data/new_allocations.txt") file_status = os.path.isfile(file_path) self.assertTrue(file_status) def test_allocations_outputs_screen(self): """ Tests whether allocations can be printed on file: new_allocations. """ staff = self.staff[-1] self.amity.allocate_person(str(staff.employee_id)) data = self.amity.print_allocations() self.assertTrue(data) def test_output_when_no_room(self): """ Test print_allocations when no rooms in the system """ self.amity.offices = [] self.amity.living_spaces = [] data = self.amity.print_allocations() self.assertIn("No Rooms Found.", data) def test_output_to_file(self): """ Tests whether the unallocated can be printed on file: new_unallocated. """ staff = self.staff[-1] self.amity.allocate_person(str(staff.employee_id)) self.amity.print_unallocated("new_unallocated") file_path = os.path.abspath("data/new_unallocated.txt") file_status = os.path.isfile(file_path) self.assertTrue(file_status) def test_unallocated_outputs_screen(self): """ Tests whether the unallocated can be printed on file: new_unallocated. """ staff = self.staff[-1] self.amity.allocate_person(str(staff.employee_id)) data = self.amity.print_unallocated() self.assertTrue(data) def test_print_non_existent_room(self): """ Test whether a non-existent room can be printed on screen. """ print_room = self.amity.print_room("arkham") self.assertIn("Room not found!", print_room) def test_when_no_occupants_in_room(self): """ Test whether a room with no occupants can be printed on screen. """ print_room = self.amity.print_room("mombasa") self.assertIn("No occupants in room", print_room) def test_print_correct_occupants(self): """ Test whether a room and its occupants can be printed on screen. """ fellow = self.fellows[-1] self.amity.allocate_person(str(fellow.employee_id)) print_room = self.amity.print_room("mombasa") self.assertIn("Hum Musonye", print_room) def test_save_state_creates_db(self): """ Test whether save_state creates a SQLite database. """ self.amity.save_state("test") file_path = os.path.abspath("test.db") file_status = os.path.isfile(file_path) self.assertTrue(file_status) def test_non_existent_db(self): """ Tests how load_state behaves when passed a nn existent db name. """ load_state = self.amity.load_state("amity_lagos") self.assertEqual("Database amity_lagos.db not found!", load_state) def test_load_test(self): """ Test whether load_state persists data from db to amity system. """ self.amity.add_person("bat", "man", "fellow", "Y") self.amity.save_state("test_load") self.amity.load_state("test_load") is_loaded = True if len(self.amity.fellows) > 1 else False self.assertTrue(is_loaded)
class TestAmity(unittest.TestCase): def setUp(self): self.engine = create_engine('sqlite:///:memory:') session = sessionmaker(self.engine) session.configure(bind=self.engine) self.session = session() sys.stdout = StringIO() self.amity = Amity() self.Base = declarative_base() # Base.metadata.create_all(self.engine) # self.panel = Panel(1, 'ion torrent', 'start') # self.session.add(self.panel) # self.session.commit() def test_type_of_amity(self): self.assertIsInstance(Amity(), object) @patch('amity.Amity.connect_db') def test_create_tables(self, mock_connect_db): mock_connect_db.return_value = self.engine self.amity.create_tables() # assert table user exists self.assertTrue(self.engine.dialect.has_table( self.engine.connect(), "user")) # assert table room exists self.assertTrue(self.engine.dialect.has_table( self.engine.connect(), "room")) @patch('amity.Amity.connect_db') @patch('amity.Amity.retrieve_data_from_db') def test_load_state(self, mock_connect_db, mock_retrieve_data_from_db): mock_connect_db.return_value = self.engine mock_retrieve_data_from_db.return_value = True self.amity.load_state() printed = sys.stdout.getvalue() self.assertIn( "Please Wait... This may take some few minutes.", printed) self.assertIn("\tReading data from the database", printed) self.assertIn("Load State successfully completed", printed) self.assertIn('', printed) def test_retrieve_data_from_db(self): class User(self.Base): '''class mapper for table user''' __tablename__ = 'user' id = Column(Integer, Sequence('user_id_seq'), primary_key=True) person_name = Column(String(30)) type_person = Column(String(30)) class Room(self.Base): '''class mapper for table room''' __tablename__ = 'room' id = Column(Integer, Sequence('room_id_seq'), primary_key=True) room_type = Column(String(20)) room_name = Column(String(30)) occupant1 = Column(String(30), ForeignKey('user.id')) occupant2 = Column(String(30), ForeignKey('user.id')) occupant3 = Column(String(30), ForeignKey('user.id')) occupant4 = Column(String(30), ForeignKey('user.id')) occupant5 = Column(String(30), ForeignKey('user.id')) occupant6 = Column(String(30), ForeignKey('user.id')) self.Base.metadata.create_all(self.engine) if self.engine.dialect.has_table(self.engine.connect(), "user"): print('user') test_User = Table("user", MetaData(self.engine), autoload=True) sample_data = {'person_name': 'andela-jkariuki', 'type_person': 'fellow'} test_User.insert().execute(sample_data) elif self.engine.dialect.has_table(self.engine.connect(), "room"): test_Room = Table("room", MetaData(self.engine), autoload=True) sample_data = {'room_name': 'php', 'room_type': 'livingspace', 'occupant1': 'Morris', 'occupant2': 'Migwi'} test_Room.insert().execute(sample_data) self.amity.retrieve_data_from_db(self.session) self.assertIn('andela-jkariuki', Fellow.fellow_names) self.assertNotIn('php', list(LivingSpace.room_n_occupants.keys())) @patch('amity.Amity.connect_db') @patch('amity.Amity.create_tables') @patch('amity.Amity.order_data_ready_for_saving') def test_save_state(self, mock_connect_db, mock_create_tables, mock_order_data_ready_for_saving): mock_connect_db.return_value = self.engine mock_create_tables.return_value = True mock_order_data_ready_for_saving.return_value = True sys.stdout = StringIO() self.amity.save_state() printed = sys.stdout.getvalue() self.assertIn( "Please Wait... This may take some few minutes.", printed) self.assertIn("\tInitiating database population....", printed) self.assertIn("\tFinalizing database population....", printed) self.assertIn("Save State successfully completed.", printed) @patch('app.fellow.Fellow.fellow_names') @patch('app.staff.Staff.staff_names') @patch.dict('app.office.Office.office_n_occupants', {'Round_Table': ['Sass', 'Joshua', 'Jeremy'], 'Krypton': ['Percila', 'Kimani', 'Whitney'], 'Valhala': ['Migwi'] }) @patch.dict('app.livingspace.LivingSpace.room_n_occupants', {'php': ['Andela1', 'andela2', 'Mr know it all'], 'amity': ['chiemeka', 'mayowa', 'chioma'], 'm55': ['adeleke'] }) def test_order_data_ready_for_saving(self, mock_fellow_names, mock_staff_names): class User(self.Base): '''class mapper for table user''' __tablename__ = 'user' id = Column(Integer, Sequence('user_id_seq'), primary_key=True) person_name = Column(String(30)) type_person = Column(String(30)) class Room(self.Base): '''class mapper for table room''' __tablename__ = 'room' id = Column(Integer, Sequence('room_id_seq'), primary_key=True) room_type = Column(String(20)) room_name = Column(String(30)) occupant1 = Column(String(30), ForeignKey('user.id')) occupant2 = Column(String(30), ForeignKey('user.id')) occupant3 = Column(String(30), ForeignKey('user.id')) occupant4 = Column(String(30), ForeignKey('user.id')) occupant5 = Column(String(30), ForeignKey('user.id')) occupant6 = Column(String(30), ForeignKey('user.id')) self.Base.metadata.create_all(self.engine) mock_fellow_names.__iter__.return_value = ['chiemeka', 'mayowa', 'Andela1', 'andela2', 'adeleke'] mock_staff_names.__iter__.return_value = ['Sass', 'Joshua', 'Jeremy', 'chioma', 'Mr know it all'] self.amity.order_data_ready_for_saving(self.session) self.session.commit() self.session.flush() # check if table user exists all_rooms = {} all_users = [] if self.engine.dialect.has_table(self.engine.connect(), "user"): test_User = Table("user", MetaData(self.engine), autoload=True) all_users = test_User.select().execute() print(all_rooms) elif self.engine.dialect.has_table(self.engine.connect(), "room"): test_Room = Table("room", MetaData(self.engine), autoload=True) all_rooms = test_Room.select().execute() print(all_users) self.assertNotIn(frozenset({'Valhala': ['Migwi']}), all_rooms) self.assertNotIn(['Mr know it all', 'adeleke'], all_users) def test_print_file(self): data = {'The_Key': 'The value'} sample_text = 'Room Name: The_Key Occupants:The value \n\r' with patch("builtins.open", mock_open(read_data=sample_text)) as mock_file: self.amity.print_file('sample', 'allocated', data) mock_file.assert_called_with('sample-allocated.txt', 'w') # mock_file.write.assert_called_once_with(sample_text, 'w') assert open('sample-allocated.txt', 'w').read() == sample_text @patch('app.person.Person.add_person') def test_load_people(self, mock_add_person): sample_read_text = 'andela-dmigwi FELLOW Y' mock_add_person.return_value = 'Successful' with patch("builtins.open", mock_open(read_data=sample_read_text)) as mock_file: self.amity.load_people() # assert open("people.txt", 'r').readlines() == sample_read_text mock_file.assert_called_with("people.txt", 'r') printed = sys.stdout.getvalue() self.assertIn('Successful', printed) @patch('amity.Amity.compute_rooms') @patch('amity.Amity.print_file') def test_get_allocations(self, mock_print_file, mock_compute_rooms): mock_compute_rooms.return_value = {'Amity': ['Eston Mwaura']} mock_print_file.return_value = 'Successful' room_details = self.amity.get_allocations('test.txt') office_details = {'Amity': ['Eston Mwaura']} livingspace_details = 'Successful' self.assertIn(office_details, room_details) self.assertIn(livingspace_details, room_details) @patch('amity.Amity.compute_rooms') @patch('amity.Amity.print_file') def test_get_unallocated(self, mock_print_file, mock_compute_rooms): mock_compute_rooms.return_value = ['Amity'] mock_print_file.return_value = 'Successful' room_details = self.amity.get_unallocated('sample.txt') response_office = ['Amity', 'Amity'] response_livingspace = 'Successful' self.assertIn(response_office, room_details) self.assertIn(response_livingspace, room_details) def test_compute(self): rooms = {'m55': ['Aubrey, Chiemeka', 'Mayowa'], 'Amity': [], 'Dojo': ['Migwi', 'Elsis']} computed = self.amity.compute_rooms(rooms, 'allocated') rooms_1 = {'m55': ['Aubrey, Chiemeka', 'Mayowa'], 'Dojo': ['Migwi', 'Elsis']} self.assertEqual(computed, rooms_1) computed = self.amity.compute_rooms(rooms, 'unallocated') self.assertEqual(computed, ['Amity']) @patch.dict('app.office.Office.office_n_occupants', {'Dojo': ['Njira']}) @patch.dict('app.livingspace.LivingSpace.room_n_occupants', {'Valhala': ['Edwin']}) @patch('app.staff.Staff.staff_names') @patch('app.fellow.Fellow.fellow_names') def test_get_all_unallocated_people(self, mock_fellow_names, mock_staff_names): mock_fellow_names.__iter__.return_value = ['Lolo', 'Edwin'] mock_staff_names.__iter__.return_value = ['Eston', 'Njira'] check = self.amity.get_all_unallocated_people() self.assertIn('Lolo', check[0]) self.assertIn('Eston', check[2])
class ScreenOut(cmd.Cmd): """main class""" os.system('clear') fig_font = Figlet(font='poison', justify='left', width=200) print("\n") print(colored(fig_font.renderText('( AMITY )'),\ 'green', attrs=['bold'])) intro = colored('Version 1.0\t\t Enter "quit" to exit \n', 'green', attrs=['bold']) nice = colored('(amity) ~ ', 'cyan', attrs=['blink']) prompt = nice def __init__(self): cmd.Cmd.__init__(self) self.amity = Amity() @docopt_cmd def do_create_room(self, args): """Usage: create_room <room_type> <room_name>...""" room_type = args['<room_type>'] room_names = args['<room_name>'] msg = self.amity.create_room(room_type, *room_names) if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg += ' ✔' msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_add_person(self, args): """Usage: add_person <fname> <lname> <role> [<wants_accomodation>]""" fname = args['<fname>'] lname = args['<lname>'] role = args['<role>'] wants_accomodation = args['<wants_accomodation>'] try: if wants_accomodation.upper() not in ['Y', 'N']: msg = "Invalid accomodation parameter! Please use Y or N ✘" msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) if role.upper() not in ['FELLOW', 'STAFF']: msg = "Invalid role parameter! Please use FELLOW or STAFF ✘" msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg = self.amity.add_person(fname, lname, role, wants_accomodation) msg += ' ✔' msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) except AttributeError: msg = "Please indicate if person wants accomodation! ✘" msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_allocate_person(self, args): """Usage: allocate_person <person_id>""" person_id = args['<person_id>'] msg = self.amity.allocate_person(person_id) if "!" not in msg: msg += ' ✔' msg = colored(msg, 'yellow', attrs=['bold', 'dark']) print(msg) else: msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_reallocate_person(self, args): """Usage: reallocate_person <person_id> <new_room_name>""" person_id = args['<person_id>'] room = args['<new_room_name>'] msg = self.amity.reallocate_person(person_id, room) if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg += ' ✔' msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_load_people(self, arg): """Usage: load_people""" msg = self.amity.load_people('people') if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg += ' ✔' msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_print_allocations(self, args): """Usage: print_allocations [--o=filename.txt]""" if args['--o']: filename = args['--o'] msg = self.amity.print_allocations(filename) if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg += ' ✔' msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) else: msg = self.amity.print_allocations() if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg = colored(msg, 'yellow', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_print_unallocated(self, args): """Usage: print_unallocated [--o=filename.txt]""" if args['--o']: filename = args['--o'] msg = self.amity.print_unallocated(filename) if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg += ' ✔' msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) else: msg = self.amity.print_unallocated() if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg = colored(msg, 'yellow', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_print_room(self, args): """Usage: print_room <room_name>""" room_name = args['<room_name>'] msg = self.amity.print_room(room_name) if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg += ' ✔' msg = colored(msg, 'yellow', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_save_state(self, args): """Usage: save_state [--db=sqlite_database]""" db = args['--db'] msg = self.amity.save_state(db) if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg += ' ✔' msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) @docopt_cmd def do_load_state(self, args): """Usage: load_state [<sqlite_database>]""" db = args['<sqlite_database>'] msg = self.amity.load_state(db) if "!" in msg: msg += ' ✘' msg = colored(msg, 'red', attrs=['bold', 'dark']) print(msg) else: msg = colored(msg, 'green', attrs=['bold', 'dark']) print(msg) def do_quit(self, arg): """Quits out of Interactive Mode.""" os.system('clear') bye = Figlet(font='jazmine') delay_print('\n\n' + \ colored(bye.renderText('Bye ...'), 'yellow', attrs=['bold'])) exit()