예제 #1
0
 def testNoCommand(self):
     runtime = Runtime()
     commands = CommandsMockup()
     for keywords in PARSER_KEYWORDS:
         runtime.parser.add_keywords(keywords)
     runtime.add_mapping([('count', 'KEYWORD'),('event', 'KEYWORD')], 
                         commands.printEventCount)
     runtime.add_mapping([('load', 'KEYWORD'),('', 'DATE')], 
                         commands.loadData)
     counter = 0
     with open(COMMANDS_FILE, "r") as commands_file:
         for line in commands_file:
             line = line.strip()
             if len(line) > 0 and line[0] != '#':
                 tokens = line.split('->')
                 self.assertEqual(2, len(tokens))
                 runtime.execute(tokens[0])
                 self.assertEqual(tokens[1].strip(), commands.result)
                 counter += 1
     print('Processed %d commands' % counter)
예제 #2
0
 def testContainsTrue(self):
     runtime = Runtime()
     tokens = [('ala', ''), ('ma', ''), ('kota', 'NN')]
     words = [('ala', ''), ('kota', 'NN')]
     self.assertTrue(runtime._contains(tokens, words))
예제 #3
0
 def testContainsFalse(self):
     runtime = Runtime()
     tokens = [('ala', ''), ('ma', ''), ('kota', '')]
     words = [('alexandra', '')]
     self.assertFalse(runtime._contains(tokens, words))