2022-03-09 15:37:04 -08:00
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
import json
|
2022-09-23 16:19:35 -07:00
|
|
|
from typing import Dict
|
2022-11-01 17:01:21 -07:00
|
|
|
from jc.parsers.foo import parse
|
2022-03-09 15:37:04 -08:00
|
|
|
|
|
|
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
|
|
|
|
class MyTests(unittest.TestCase):
|
2022-09-23 16:19:35 -07:00
|
|
|
f_in: Dict = {}
|
|
|
|
f_json: Dict = {}
|
2022-03-09 15:37:04 -08:00
|
|
|
|
2022-09-23 16:19:35 -07:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
fixtures = {
|
|
|
|
'centos_7_7_foo': (
|
|
|
|
'fixtures/centos-7.7/foo.out',
|
|
|
|
'fixtures/centos-7.7/foo.json')
|
|
|
|
}
|
2022-09-23 10:58:28 -07:00
|
|
|
|
2022-09-23 16:19:35 -07:00
|
|
|
for file, filepaths in fixtures.items():
|
2022-09-23 16:30:43 -07:00
|
|
|
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
|
|
|
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
|
|
|
cls.f_in[file] = a.read()
|
|
|
|
cls.f_json[file] = json.loads(b.read())
|
2022-03-09 15:37:04 -08:00
|
|
|
|
|
|
|
|
|
|
|
def test_foo_nodata(self):
|
|
|
|
"""
|
|
|
|
Test 'foo' with no data
|
|
|
|
"""
|
2022-11-01 17:01:21 -07:00
|
|
|
self.assertEqual(parse('', quiet=True), [])
|
|
|
|
|
2022-03-09 15:37:04 -08:00
|
|
|
|
|
|
|
def test_foo_centos_7_7(self):
|
|
|
|
"""
|
|
|
|
Test 'foo' on Centos 7.7
|
|
|
|
"""
|
2022-11-22 13:11:10 -08:00
|
|
|
self.assertEqual(
|
|
|
|
parse(self.f_in['centos_7_7_foo'], quiet=True),
|
2022-11-01 17:01:21 -07:00
|
|
|
self.f_json['centos_7_7_foo']
|
|
|
|
)
|
2022-03-09 15:37:04 -08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|