From cc7def9b76a7fa6de1e11b584676820f3acb0257 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 6 Apr 2021 11:29:30 -0700 Subject: [PATCH] add OSX finger tests --- tests/fixtures/osx-10.14.6/finger.json | 1 + tests/fixtures/osx-10.14.6/finger.out | 5 +++++ tests/test_finger.py | 12 ++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 tests/fixtures/osx-10.14.6/finger.json create mode 100644 tests/fixtures/osx-10.14.6/finger.out diff --git a/tests/fixtures/osx-10.14.6/finger.json b/tests/fixtures/osx-10.14.6/finger.json new file mode 100644 index 00000000..b7837906 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/finger.json @@ -0,0 +1 @@ +[{"login":"kbrazil","name":"kbrazil","tty":"con","idle":"15d","login_time":"Mar 22 07:33","tty_writeable":false,"idle_minutes":0,"idle_hours":0,"idle_days":15,"total_idle_minutes":21600},{"login":"kbrazil","name":"kbrazil","tty":"s00","idle":null,"login_time":"Mar 22 07:34","tty_writeable":true,"idle_minutes":0,"idle_hours":0,"idle_days":0,"total_idle_minutes":0},{"login":"kbrazil","name":"kbrazil","tty":"s00","idle":"8","tty_writeable":true,"idle_minutes":8,"idle_hours":0,"idle_days":0,"total_idle_minutes":8},{"login":"kbrazil","name":"kbrazil","tty":"s00","idle":"1:19","login_time":"Mar 22 07:34","tty_writeable":true,"idle_minutes":19,"idle_hours":1,"idle_days":0,"total_idle_minutes":79}] diff --git a/tests/fixtures/osx-10.14.6/finger.out b/tests/fixtures/osx-10.14.6/finger.out new file mode 100644 index 00000000..d0ab5fde --- /dev/null +++ b/tests/fixtures/osx-10.14.6/finger.out @@ -0,0 +1,5 @@ +Login Name TTY Idle Login Time Office Phone +kbrazil kbrazil *con 15d Mar 22 07:33 +kbrazil kbrazil s00 Mar 22 07:34 +kbrazil kbrazil s00 8 Tue 09:04 +kbrazil kbrazil s00 1:19 Mar 22 07:34 diff --git a/tests/test_finger.py b/tests/test_finger.py index c1b53123..6230c961 100644 --- a/tests/test_finger.py +++ b/tests/test_finger.py @@ -16,6 +16,9 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/finger.out'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_finger = f.read() + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/finger.out'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_finger = f.read() + # output with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/finger.json'), 'r', encoding='utf-8') as f: self.centos_7_7_finger_json = json.loads(f.read()) @@ -23,6 +26,9 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/finger.json'), 'r', encoding='utf-8') as f: self.ubuntu_18_4_finger_json = json.loads(f.read()) + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/finger.json'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_finger_json = json.loads(f.read()) + def test_finger_nodata(self): """ @@ -42,6 +48,12 @@ class MyTests(unittest.TestCase): """ self.assertEqual(jc.parsers.finger.parse(self.ubuntu_18_4_finger, quiet=True), self.ubuntu_18_4_finger_json) + def test_finger_osx_10_14_6(self): + """ + Test plain 'finger' on OSX 10.14.6 + """ + self.assertEqual(jc.parsers.finger.parse(self.osx_10_14_6_finger, quiet=True), self.osx_10_14_6_finger_json) + if __name__ == '__main__': unittest.main()