1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

add test template

This commit is contained in:
Kelly Brazil
2022-03-09 15:37:04 -08:00
parent 845d763829
commit 5e7a87f397

35
tests/_test_foo.py Normal file
View File

@ -0,0 +1,35 @@
import os
import unittest
import json
import jc.parsers.foo
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
def setUp(self):
# input
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/foo.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_foo = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/foo.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_foo_json = json.loads(f.read())
def test_foo_nodata(self):
"""
Test 'foo' with no data
"""
self.assertEqual(jc.parsers.foo.parse('', quiet=True), [])
def test_foo_centos_7_7(self):
"""
Test 'foo' on Centos 7.7
"""
self.assertEqual(jc.parsers.foo.parse(self.centos_7_7_foo, quiet=True), self.centos_7_7_foo_json)
if __name__ == '__main__':
unittest.main()