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

43 lines
1.3 KiB
Python
Raw Normal View History

2022-12-19 22:13:58 -05:00
import os
import json
import unittest
import jc.parsers.iwconfig
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class iwconfigTests(unittest.TestCase):
# input
with open(os.path.join(THIS_DIR, 'fixtures/ubuntu-20.10/iwconfig.out'), 'r', encoding='utf-8') as f:
ubuntu_20_10_iwconfig= f.read()
# output
with open(os.path.join(THIS_DIR, 'fixtures/ubuntu-20.10/iwconfig.json'), 'r', encoding='utf-8') as f:
ubuntu_20_10_iwconfig_json= json.loads(f.read())
2022-12-19 22:36:48 -05:00
with open(os.path.join(THIS_DIR, 'fixtures/ubuntu-20.10/iwconfig-raw.json'), 'r', encoding='utf-8') as f:
ubuntu_20_10_iwconfig_raw_json= json.loads(f.read())
2022-12-19 22:13:58 -05:00
def test_iwconfig_nodata(self):
"""
Test 'iwconfig' with no data
"""
self.assertEqual(jc.parsers.iwconfig.parse('', quiet=True), [])
2022-12-19 22:36:48 -05:00
def test_iwconfig_ubuntu_20_04(self):
"""
Test 'iwconfig' raw on Ubuntu 20.10
"""
self.assertEqual(jc.parsers.iwconfig.parse(self.ubuntu_20_10_iwconfig, quiet=True, raw=True), self.ubuntu_20_10_iwconfig_raw_json)
2022-12-19 22:13:58 -05:00
def test_iwconfig_ubuntu_20_04(self):
"""
Test 'iwconfig' on Ubuntu 20.10
"""
self.assertEqual(jc.parsers.iwconfig.parse(self.ubuntu_20_10_iwconfig, quiet=True), self.ubuntu_20_10_iwconfig_json)
if __name__ == '__main__':
unittest.main()