File: validator_test.py

package info (click to toggle)
forensic-artifacts 20161022-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 572 kB
  • ctags: 189
  • sloc: python: 1,165; makefile: 50; sh: 47
file content (36 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the artifact definitions validator."""

import glob
import os
import unittest

from artifacts import errors
from tools import validator


class ArtifactDefinitionsValidatorTest(unittest.TestCase):
  """Class to test the validator."""

  def testArtifactDefinitionsValidator(self):
    """Runs the validator over all the YAML artifact definitions files."""
    validator_object = validator.ArtifactDefinitionsValidator()

    for definitions_file in glob.glob(os.path.join('definitions', '*.yaml')):
      result = validator_object.CheckFile(definitions_file)
      self.assertTrue(result,
                      msg='in definitions file: {0}'.format(definitions_file))

    undefined_artifacts = validator_object.GetUndefinedArtifacts()
    if undefined_artifacts:
      raise errors.MissingDependencyError(
          'Artifacts group referencing undefined artifacts: {0}'.format(
              undefined_artifacts))

  # TODO: add tests that deliberately provide invalid definitions to see
  # if the validator works correctly.


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