fw4spl
test_check_xml.py
1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
3 
4 import os
5 import unittest
6 
7 import check_xml
8 import common
9 
10 
11 class TestCheckXml(unittest.TestCase):
12  def test_check_xml_with_valid_xml_file(self):
13  # Be verbose by default
14  common.g_trace = True
15 
16  # Load the test file
17  dir_path = os.path.dirname(os.path.realpath(__file__))
18  file = common.file_on_disk(dir_path + '/data/check_xml_valid.xml')
19 
20  # Apply the hook
21  result = check_xml.check_xml(file)
22 
23  # Check result
24  self.assertFalse(result, "Valid xml detected as invalid.")
25 
26  def test_check_xml_with_invalid_xml_file(self):
27  # Be verbose by default
28  common.g_trace = True
29 
30  # Load the test file
31  dir_path = os.path.dirname(os.path.realpath(__file__))
32  file = common.file_on_disk(dir_path + '/data/check_xml_invalid.xml')
33 
34  # Apply the hook
35  result = check_xml.check_xml(file)
36 
37  # Check result
38  self.assertTrue(result, "Invalid xml detected as valid.")
39 
40 
41 if __name__ == '__main__':
42  unittest.main()
def check_xml(files)
Definition: check_xml.py:32
def file_on_disk(path)
Definition: common.py:314