#!/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) #valid inputs: c.sendline("rfq \"lskejdf\"") assert c.expect_exact("\nThe Joker :: \"Oh, you. You just couldn't let me go, could you? This is what happens when an unstoppable force meets an immovable object. You truly are incorruptible, aren't you? You won't kill me out of some misplaced sense of self-righteousness. And I won't kill you because you're just too much fun. I think you and I are destined to do this forever.\"\n\n-The Dark Knight (2008)\n\n") == 0, "seed 'lskejdf' resulted in unexpected film quote" c.sendline("rfq \"8495136\"") assert c.expect_exact("\nJohn Malkovich :: \"Malkovich Malkovich? Malkovich Malkovich Malkovich.\"\n\n-Being John Malkovich (1999)\n\n") == 0, "seed '8495136' resulted in unexpected film quote" c.sendline("rfq \"54;lk6j45w\"") assert c.expect_exact("\nTom :: \"Seems? Well, this seems to be a waste of my time. That is 900 nicker in any shop you're lucky enough to find one in. And you're complaining about 200? What school of finance did you study? 'It's a deal, it's a steal, it's the sale of the fucking century!' In fact, fuck it Nick, I think I'll keep it!\"\n\n-Lock Stock and Two Smoking Barrels (1998)\n\n") == 0, "seed '54;lk6j45w' resulted in unexpected film quote" #test successful shellio.success()