# -*- encoding: UTF8 -*-
from __future__ import print_function
import sys
import unittest
from JobsCmdFilter import JobsCmdFilter
python3 = sys.version_info[0] >= 3
class TestJobsCmdFilter(unittest.TestCase):
def __init__(self, methodName='runTest'):
super(TestJobsCmdFilter, self).__init__(methodName=methodName)
def assertRegex(self, *args, **kwargs):
if python3:
return super(TestJobsCmdFilter, self).assertRegex(*args, **kwargs)
else:
return super(TestJobsCmdFilter, self).assertRegexpMatches(*args, **kwargs)
def setUp(self):
pass
def tearDown(self):
pass
def testJobsFilter(self):
"ordinary jobs command is OK"
trig = JobsCmdFilter()
self.assertEqual(0, trig.run())
trig = JobsCmdFilter("")
self.assertEqual(0, trig.run())
trig = JobsCmdFilter('-e', 'new')
self.assertEqual(0, trig.run())
trig = JobsCmdFilter("-r", "-m100", "-e", "Summary='****'")
self.assertEqual(1, trig.run())
trig = JobsCmdFilter("-r", "-m100", "-e", "Summary='**'")
self.assertEqual(1, trig.run())
trig = JobsCmdFilter("-r", "-e", "fred**")
self.assertEqual(1, trig.run())
if __name__ == '__main__':
unittest.main()