2020-02-04 21:25:33 -08:00
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import unittest
|
|
|
|
import jc.parsers.id
|
|
|
|
|
|
|
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
|
|
|
|
class MyTests(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
# input
|
2020-03-04 19:40:32 -08:00
|
|
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/id.out'), 'r', encoding='utf-8') as f:
|
2020-02-04 21:25:33 -08:00
|
|
|
self.centos_7_7_id = f.read()
|
|
|
|
|
2020-03-04 19:40:32 -08:00
|
|
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/id.out'), 'r', encoding='utf-8') as f:
|
2020-02-04 21:25:33 -08:00
|
|
|
self.osx_10_14_6_id = f.read()
|
|
|
|
|
|
|
|
# output
|
2020-03-04 19:40:32 -08:00
|
|
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/id.json'), 'r', encoding='utf-8') as f:
|
2020-02-04 21:25:33 -08:00
|
|
|
self.centos_7_7_id_json = json.loads(f.read())
|
|
|
|
|
2020-03-04 19:40:32 -08:00
|
|
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/id.json'), 'r', encoding='utf-8') as f:
|
2020-02-04 21:25:33 -08:00
|
|
|
self.osx_10_14_6_id_json = json.loads(f.read())
|
|
|
|
|
2020-06-10 17:54:06 -07:00
|
|
|
def test_id_nodata(self):
|
|
|
|
"""
|
|
|
|
Test 'id' with no data
|
|
|
|
"""
|
|
|
|
self.assertEqual(jc.parsers.id.parse('', quiet=True), {})
|
|
|
|
|
2020-02-04 21:25:33 -08:00
|
|
|
def test_id_centos_7_7(self):
|
|
|
|
"""
|
|
|
|
Test 'id' on Centos 7.7
|
|
|
|
"""
|
|
|
|
self.assertEqual(jc.parsers.id.parse(self.centos_7_7_id, quiet=True), self.centos_7_7_id_json)
|
|
|
|
|
|
|
|
def test_id_osx_10_14_6(self):
|
|
|
|
"""
|
|
|
|
Test 'id' on OSX 10.14.6
|
|
|
|
"""
|
|
|
|
self.assertEqual(jc.parsers.id.parse(self.osx_10_14_6_id, quiet=True), self.osx_10_14_6_id_json)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|