Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjonbrazil committed Oct 23, 2023
1 parent 741b2d1 commit 63c271b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/fixtures/generic/who-login-screen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"user":"atemu","tty":"seat0","time":"2023-10-21 20:06","from":"login screen","epoch":1697943960},{"user":"atemu","tty":":0","time":"2023-10-21 20:06","from":":0","epoch":1697943960},{"user":"atemu","tty":"pts/8","time":"2023-10-23 18:27","epoch":1698110820}]
3 changes: 3 additions & 0 deletions tests/fixtures/generic/who-login-screen.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
atemu seat0 2023-10-21 20:06 (login screen)
atemu :0 2023-10-21 20:06 (:0)
atemu pts/8 2023-10-23 18:27
11 changes: 11 additions & 0 deletions tests/test_who.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/who-a.out'), 'r', encoding='utf-8') as f:
osx_10_14_6_who_a = f.read()

with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/who-login-screen.out'), 'r', encoding='utf-8') as f:
generic_who_login_screen = f.read()

# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/who.json'), 'r', encoding='utf-8') as f:
centos_7_7_who_json = json.loads(f.read())
Expand All @@ -53,6 +56,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/who-a.json'), 'r', encoding='utf-8') as f:
osx_10_14_6_who_a_json = json.loads(f.read())

with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/who-login-screen.json'), 'r', encoding='utf-8') as f:
generic_who_login_screen_json = json.loads(f.read())


def test_who_nodata(self):
"""
Expand Down Expand Up @@ -96,6 +102,11 @@ def test_who_a_osx_10_14_6(self):
"""
self.assertEqual(jc.parsers.who.parse(self.osx_10_14_6_who_a, quiet=True), self.osx_10_14_6_who_a_json)

def test_who_login_screen(self):
"""
Test 'who' with (login screen) as remote
"""
self.assertEqual(jc.parsers.who.parse(self.generic_who_login_screen, quiet=True), self.generic_who_login_screen_json)

if __name__ == '__main__':
unittest.main()

0 comments on commit 63c271b

Please sign in to comment.