#!/usr/bin/python # # ccl python test file: Tests our ccl builtin plugin # # This test will check a few valid inputs for CCL and a few #invalid inputs to ensure the plug-in works as anticipated. 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) #some valid inputs: c.sendline("ccl ahri") assert c.expect_exact("\n1. LeBlanc\n2. Talon\n3. Annie\n4. Kassadin\n\n") == 0, "incorrect output printed for 'ccl ahri'" c.sendline("ccl \"master yi\"") assert c.expect_exact("\n1. Jax\n2. Teemo\n3. Cho'Gath\n4. Aatrox\n\n") == 0, "incorrect output printed for 'ccl \"master yi\"'" c.sendline("ccl \"kha'zix\"") assert c.expect_exact("\n1. Lee Sin\n2. Jayce\n3. Jax\n4. Yorick\n\n") == 0, "incorrect output printed for 'ccl \"kha'zix\"'" #some invalid inputs: c.sendline("ccl") assert c.expect_exact("\nInput champion name not recognized. Champion names must be in lowercase and names with spaces or apostrophes must be enclosed in quotations: e.g. 'ccl ahri', 'ccl \"master yi\", 'ccl \"kha'zix\"' \n\n") == 0, "Command without parameters resulted in incorrect output" c.sendline("ccl master yi") assert c.expect_exact("\nInput champion name not recognized. Champion names must be in lowercase and names with spaces or apostrophes must be enclosed in quotations: e.g. 'ccl ahri', 'ccl \"master yi\", 'ccl \"kha'zix\"' \n\n") == 0, "Command with multiple parameters resulted in incorrect output" #test successful shellio.success()