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

tests passing for airport -I. Issue #46

This commit is contained in:
Kelly Brazil
2020-03-10 21:02:17 -07:00
parent 52494321fc
commit 553bfbe1a0
3 changed files with 40 additions and 6 deletions

View File

@ -3,7 +3,10 @@ jc - JSON CLI output utility airport Parser
Usage: Usage:
specify --airport as the first argument if the piped input is coming from airport specify --airport as the first argument if the piped input is coming from airport (OSX)
This program can be found at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
Compatibility: Compatibility:
@ -11,7 +14,7 @@ Compatibility:
Examples: Examples:
$ airport | jc --airport -p $ airport -I | jc --airport -p
{ {
"agrctlrssi": -66, "agrctlrssi": -66,
"agrextrssi": 0, "agrextrssi": 0,
@ -30,7 +33,7 @@ Examples:
"channel": "48,80" "channel": "48,80"
} }
$ airport | jc --airport -p -r $ airport -I | jc --airport -p -r
{ {
"agrctlrssi": "-66", "agrctlrssi": "-66",
"agrextrssi": "0", "agrextrssi": "0",

View File

@ -2,7 +2,10 @@
Usage: Usage:
specify --airport as the first argument if the piped input is coming from airport specify --airport as the first argument if the piped input is coming from airport (OSX)
This program can be found at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
Compatibility: Compatibility:
@ -10,7 +13,7 @@ Compatibility:
Examples: Examples:
$ airport | jc --airport -p $ airport -I | jc --airport -p
{ {
"agrctlrssi": -66, "agrctlrssi": -66,
"agrextrssi": 0, "agrextrssi": 0,
@ -29,7 +32,7 @@ Examples:
"channel": "48,80" "channel": "48,80"
} }
$ airport | jc --airport -p -r $ airport -I | jc --airport -p -r
{ {
"agrctlrssi": "-66", "agrctlrssi": "-66",
"agrextrssi": "0", "agrextrssi": "0",

28
tests/test_airport.py Normal file
View File

@ -0,0 +1,28 @@
import os
import unittest
import json
import jc.parsers.airport
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/osx-10.14.6/airport-I.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_airport_I = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/airport-I.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_airport_I_json = json.loads(f.read())
def test_airport_I_osx_10_14_6(self):
"""
Test 'airport -I' on OSX 10.14.6
"""
self.assertEqual(jc.parsers.airport.parse(self.osx_10_14_6_airport_I, quiet=True), self.osx_10_14_6_airport_I_json)
if __name__ == '__main__':
unittest.main()