diff --git a/docs/parsers/airport.md b/docs/parsers/airport.md index 81e27be0..ccd89474 100644 --- a/docs/parsers/airport.md +++ b/docs/parsers/airport.md @@ -3,7 +3,10 @@ jc - JSON CLI output utility airport Parser 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: @@ -11,7 +14,7 @@ Compatibility: Examples: - $ airport | jc --airport -p + $ airport -I | jc --airport -p { "agrctlrssi": -66, "agrextrssi": 0, @@ -30,7 +33,7 @@ Examples: "channel": "48,80" } - $ airport | jc --airport -p -r + $ airport -I | jc --airport -p -r { "agrctlrssi": "-66", "agrextrssi": "0", diff --git a/jc/parsers/airport.py b/jc/parsers/airport.py index bffa01ba..5ea938e6 100644 --- a/jc/parsers/airport.py +++ b/jc/parsers/airport.py @@ -2,7 +2,10 @@ 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: @@ -10,7 +13,7 @@ Compatibility: Examples: - $ airport | jc --airport -p + $ airport -I | jc --airport -p { "agrctlrssi": -66, "agrextrssi": 0, @@ -29,7 +32,7 @@ Examples: "channel": "48,80" } - $ airport | jc --airport -p -r + $ airport -I | jc --airport -p -r { "agrctlrssi": "-66", "agrextrssi": "0", diff --git a/tests/test_airport.py b/tests/test_airport.py new file mode 100644 index 00000000..91907515 --- /dev/null +++ b/tests/test_airport.py @@ -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()