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

add tests

This commit is contained in:
Kelly Brazil
2023-10-23 15:39:13 -07:00
parent 741b2d1c1d
commit 63c271b837
3 changed files with 15 additions and 0 deletions

View File

@ -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}]

View File

@ -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

View File

@ -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: 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() 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 # output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/who.json'), 'r', encoding='utf-8') as f: 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()) centos_7_7_who_json = json.loads(f.read())
@ -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: 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()) 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): def test_who_nodata(self):
""" """
@ -96,6 +102,11 @@ class MyTests(unittest.TestCase):
""" """
self.assertEqual(jc.parsers.who.parse(self.osx_10_14_6_who_a, quiet=True), self.osx_10_14_6_who_a_json) 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__': if __name__ == '__main__':
unittest.main() unittest.main()