#!/usr/bin/python # # Samyak Singh (ssing94) # Michael Louie (louiem) # # officeHours_test: tests the office hours plugin. # # Test the office hour plugin for displaying office hour.s # Does not require any additional commands to be implemented # or otherwise unsable. # # SETUP #################################################################################### import sys, imp, atexit sys.path.append("/home/courses/cs3214/software/pexpect-dpty/"); import pexpect, shellio, signal, time, os, re, proc_check #Ensure the shell process is terminated def force_shell_termination(shell_process): c.close(force=True) #pulling in the regular expression and other definitions definitions_scriptname = sys.argv[1] plugin_dir = sys.argv[2] def_module = imp.load_source('', definitions_scriptname) logfile = None if hasattr(def_module, 'logfile'): logfile = def_module.logfile # spawn an instance of the shell c = pexpect.spawn(def_module.shell + plugin_dir, drainpty=True, logfile=logfile) atexit.register(force_shell_termination, shell_process=c) # set timeout for all following 'expect*' calls to 2 seconds c.timeout = 2 # TEST #################################################################################### # test "oh"; expecting print all office hours. c.sendline("oh") assert c.expect("McQ") == 0, "Failed to print all hours!" # test "oh -v"; expecting print all office hours with extra information. c.sendline("oh -v") assert c.expect("MCB") == 0, "Failed to print all hours with detailed information." # test "oh -uta"; expecting print all UTA office hours only. c.sendline("oh -uta") assert c.expect("Pruett") == 0, "Failed to print UTA hours!" # test "oh -gta"; expecting print all GTA office hours only. c.sendline("oh -gta") assert c.expect("Iqbal") == 0, "Failed to print GTA hours!" # test "oh -ins" expecting print McQuain's office hours. c.sendline("oh -ins") assert c.expect("634") == 0, "Failed to print McQuain's hours!" shellio.success()