1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-12-13 23:56:37 +02:00

update schema with nic, hyperv, and process changes

This commit is contained in:
Jon Smith
2021-04-14 08:59:17 -05:00
parent af74047b81
commit 14838f7f5d
9 changed files with 953 additions and 113 deletions

View File

@@ -7,58 +7,39 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
test_files = [
"tests/fixtures/windows/windows-7/systeminfo",
"tests/fixtures/windows/windows-10/systeminfo",
"tests/fixtures/windows/windows-10/systeminfo-hyperv",
"tests/fixtures/windows/windows-2012r2/systeminfo",
]
def setUp(self):
# input
with open(
os.path.join(
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-10/systeminfo.out"
),
"r",
encoding="utf-8",
) as f:
self.windows_10_systeminfo = f.read()
for tf in MyTests.test_files:
in_file = os.path.join(THIS_DIR, os.pardir, f"{tf}.out")
out_file = os.path.join(THIS_DIR, os.pardir, f"{tf}.json")
with open(
os.path.join(
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-7/systeminfo.out"
),
"r",
encoding="utf-8",
) as f:
self.windows_7_systeminfo = f.read()
with open(in_file, "r", encoding="utf-8") as f:
setattr(self, self.varName(tf), f.read())
with open(out_file, "r", encoding="utf-8") as f:
setattr(self, self.varName(tf) + "_json", json.loads(f.read()))
# output
with open(
os.path.join(
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-10/systeminfo.json"
),
"r",
encoding="utf-8",
) as f:
self.windows_10_systeminfo_json = json.loads(f.read())
with open(
os.path.join(
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-7/systeminfo.json"
),
"r",
encoding="utf-8",
) as f:
self.windows_7_systeminfo_json = json.loads(f.read())
def varName(self, path):
return (
path.replace("tests/fixtures/windows", "")
.replace("-", "_")
.replace("/", "_")
)
def test_windows_systeminfo(self):
"""
Test a sample Windows "systeminfo" command output
"""
self.assertEqual(
jc.parsers.systeminfo.parse(self.windows_10_systeminfo, quiet=True),
self.windows_10_systeminfo_json,
)
for tf in MyTests.test_files:
in_var = getattr(self, self.varName(tf))
out_var = getattr(self, self.varName(tf) + "_json")
self.assertEqual(
jc.parsers.systeminfo.parse(self.windows_7_systeminfo, quiet=True),
self.windows_7_systeminfo_json,
)
self.assertEqual(jc.parsers.systeminfo.parse(in_var, quiet=True), out_var)
if __name__ == "__main__":