#!/usr/bin/env python from Command import Command from datetime import datetime n_tests = 0 n_pass = 0 def testcmd(cmdline, cmd, argstr): global n_tests, n_pass n_tests += 1 print "Testing command line '%s'" % cmdline c = Command(datetime.now(), cmdline) if c.command == cmd and c.argstr == argstr: n_pass += 1 else: print " **** testcmd FAILED ****" print " command:" print " expected: '%s'" % cmd print " actual: '%s'" % c.command print " argstr:" print " expected: '%s'" % argstr print " actual: '%s'" % c.argstr print " ************************" def main(): global n_tests, n_pass testcmd('out', 'out', '') testcmd('fill', 'fill', '') testcmd('adjust', 'adjust', '') testcmd('report', 'report', '') testcmd('show', 'show', '') testcmd('@5pm out', 'out', '') testcmd('show 45h', 'show', '45h') testcmd('fill 40h', 'fill', '40h') testcmd('arlx', 'start', 'arlx') testcmd(' adjust -10m ', 'adjust', '-10m') testcmd(' @9:45 wr: nog: pbit ram test ', 'start', 'wr: nog: pbit ram test') if n_tests == n_pass: print " >= SUCCESS <=" else: print " >= FAIL <=" print "%d of %d tests pass" % (n_pass, n_tests) if __name__ == "__main__": main();