File: tagging_file.py

package info (click to toggle)
plaso 20190131-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 410,832 kB
  • sloc: python: 76,636; sh: 926; makefile: 167; xml: 70; sql: 14; vhdl: 11
file content (42 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for the tagging file."""

from __future__ import unicode_literals

import unittest

from plaso.engine import tagging_file
from plaso.lib import errors

from tests import test_lib as shared_test_lib


class TaggingFileTestCase(shared_test_lib.BaseTestCase):
  """Tests for the tagging file."""

  # pylint: disable=protected-access

  # TODO: add tests for _ParseDefinitions
  # TODO: add tests for _ParseEventTaggingRule

  @shared_test_lib.skipUnlessHasTestFile([
      'tagging_file', 'invalid_syntax.txt'])
  @shared_test_lib.skipUnlessHasTestFile(['tagging_file', 'valid.txt'])
  def testGetEventTaggingRules(self):
    """Tests the GetEventTaggingRules function."""
    test_path = self._GetTestFilePath(['tagging_file', 'valid.txt'])
    tag_file = tagging_file.TaggingFile(test_path)

    tag_expression = tag_file.GetEventTaggingRules()
    self.assertEqual(len(tag_expression.children), 5)

    test_path = self._GetTestFilePath(['tagging_file', 'invalid_syntax.txt'])
    tag_file = tagging_file.TaggingFile(test_path)

    with self.assertRaises(errors.TaggingFileError):
      tag_file.GetEventTaggingRules()


if __name__ == '__main__':
  unittest.main()