def test_shifts(self, mock_shift, mock_parse_tokenize): result = _parser._parse_text_rule('test rule') self.assertEqual('result', result) mock_parse_tokenize.assert_called_once_with('test rule') mock_shift.assert_has_calls( [mock.call('tok1', 'val1'), mock.call('tok2', 'val2')])
def test_A_and_B_or_C_with_group_and_not_7(self): for expression in [ '( @ ) and ! or not @', '@ and ( ! ) or not @', '@ and ! or not ( @ )', '@ and ! or ( not @ )', '( @ and ! ) or not @', '( @ and ! or not @ )' ]: result = _parser._parse_text_rule(expression) self.assertEqual('((@ and !) or not @)', str(result))
def test_A_and_B_or_C_with_group_and_not_7(self): for expression in ['( @ ) and ! or not @', '@ and ( ! ) or not @', '@ and ! or not ( @ )', '@ and ! or ( not @ )', '( @ and ! ) or not @', '( @ and ! or not @ )']: result = _parser._parse_text_rule(expression) self.assertEqual('((@ and !) or not @)', str(result))
def test_A_and_B_or_C_and_D(self): result = _parser._parse_text_rule('@ and ! or @ and !') self.assertEqual('((@ and !) or (@ and !))', str(result))
def test_A_or_B_and_C_or_D(self): result = _parser._parse_text_rule('@ or ! and @ or !') self.assertEqual('(@ or (! and @) or !)', str(result))
def test_A_or_B_or_C(self): result = _parser._parse_text_rule('@ or ! or @') self.assertEqual('(@ or ! or @)', str(result))
def test_fail(self, mock_parse_tokenize): result = _parser._parse_text_rule('test rule') self.assertIsInstance(result, _checks.FalseCheck) mock_parse_tokenize.assert_called_once_with('test rule')
def test_empty(self): result = _parser._parse_text_rule('') self.assertIsInstance(result, _checks.TrueCheck)
def test_A_and_B_or_C_with_group_and_not_3(self): result = _parser._parse_text_rule('not ( @ and ! or @ )') self.assertEqual('not ((@ and !) or @)', str(result))
def test_A_and_B_and_C_and_D(self): result = _parser._parse_text_rule('@ and ! and @ and !') self.assertEqual('(@ and ! and @ and !)', str(result))
def test_empty(self): result = _parser._parse_text_rule('') self.assertTrue(isinstance(result, _checks.TrueCheck))
def test_A_and_B_or_C_with_group_and_not_8(self): result = _parser._parse_text_rule('@ and ( ! or not @ )') self.assertEqual('(@ and (! or not @))', str(result))
def test_A_and_B_or_C_with_not_3(self): result = _parser._parse_text_rule('@ and ! or not @') self.assertEqual('((@ and !) or not @)', str(result))
def test_fail(self, mock_parse_tokenize): result = _parser._parse_text_rule('test rule') self.assertTrue(isinstance(result, _checks.FalseCheck)) mock_parse_tokenize.assert_called_once_with('test rule')