1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

add iw-scan tests

This commit is contained in:
Kelly Brazil
2021-01-05 21:38:51 -08:00
parent 567b887253
commit f78fe771e1
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1 @@
[{"mac_address": "00:19:a9:cd:c6:80", "interface": "wlan0", "freq": 2412, "capability": "ESS ShortPreamble ShortSlotTime (0x0421)", "ssid": "Cisco1240", "supported_rates": [1.0, 2.0, 5.5, 6.0, 9.0, 11.0, 12.0, 18.0], "erp": "<no flags>", "extended_supported_rates": [24.0, 36.0, 48.0, 54.0], "wmm": "Parameter version 1", "be": "CW 15-1023, AIFSN 3", "bk": "CW 15-1023, AIFSN 7", "vi": "CW 7-15, AIFSN 2, TXOP 3008 usec", "vo": "CW 3-7, AIFSN 2, TXOP 1504 usec", "tsf_usec": 2984923701, "beacon_interval_tus": 100, "signal_dbm": -45.0, "last_seen_ms": 429, "selected_rates": [1.0, 2.0, 5.5, 11.0], "ds_parameter_set_channel": 1}, {"mac_address": "d0:d0:fd:69:ca:70", "interface": "wlan0", "freq": 2462, "capability": "ESS ShortPreamble ShortSlotTime (0x0421)", "ssid": "Cisco1250", "supported_rates": [1.0, 2.0, 5.5, 6.0, 9.0, 11.0, 12.0, 18.0], "erp": "<no flags>", "extended_supported_rates": [24.0, 36.0, 48.0, 54.0], "wmm": "Parameter version 1", "be": "CW 15-1023, AIFSN 3", "bk": "CW 15-1023, AIFSN 7", "vi": "CW 7-15, AIFSN 2, TXOP 3008 usec", "vo": "acm CW 3-7, AIFSN 2, TXOP 1504 usec", "tsf_usec": 2968648942, "beacon_interval_tus": 102, "signal_dbm": -70.0, "last_seen_ms": 328, "selected_rates": [1.0, 2.0, 5.5, 11.0], "ds_parameter_set_channel": 11}]

File diff suppressed because one or more lines are too long

46
tests/test_iw_scan.py Normal file
View File

@ -0,0 +1,46 @@
import os
import unittest
import json
import jc.parsers.iw_scan
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/iw-scan0.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_iw_scan0 = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/iw-scan1.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_iw_scan1 = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/iw-scan0.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_iw_scan0_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/iw-scan1.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_iw_scan1_json = json.loads(f.read())
def test_iw_scan_nodata(self):
"""
Test 'iw_scan' parser with no data
"""
self.assertEqual(jc.parsers.iw_scan.parse('', quiet=True), [])
def test_iw_scan0_centos_7_7(self):
"""
Test 'iw_scan' on Centos 7.7
"""
self.assertEqual(jc.parsers.iw_scan.parse(self.centos_7_7_iw_scan0, quiet=True), self.centos_7_7_iw_scan0_json)
def test_iw_scan1_centos_7_7(self):
"""
Test 'iw_scan' on Centos 7.7
"""
self.assertEqual(jc.parsers.iw_scan.parse(self.centos_7_7_iw_scan1, quiet=True), self.centos_7_7_iw_scan1_json)
if __name__ == '__main__':
unittest.main()