mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-06 22:32:54 +02:00
add tests and fixtures for freebsd12
This commit is contained in:
1
tests/fixtures/freebsd12/last.json
vendored
Normal file
1
tests/fixtures/freebsd12/last.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Thu May 28 21:29", "logout": "still logged in"}, {"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Thu May 28 04:13", "logout": "21:29", "duration": "17:16"}, {"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Wed May 27 16:09", "logout": "04:13", "duration": "12:03"}, {"user": "root", "tty": "ttyv0", "hostname": null, "login": "Wed May 27 12:48", "logout": "still logged in"}, {"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Wed May 27 12:47", "logout": "16:09", "duration": "03:22"}, {"user": "kbrazil", "tty": "ttyv0", "hostname": null, "login": "Wed May 27 12:46", "logout": "12:48", "duration": "00:01"}, {"user": "boot time", "tty": null, "hostname": null, "login": "Wed May 27 12:46"}]
|
9
tests/fixtures/freebsd12/last.out
vendored
Normal file
9
tests/fixtures/freebsd12/last.out
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
kbrazil pts/0 192.168.71.1 Thu May 28 21:29 still logged in
|
||||||
|
kbrazil pts/0 192.168.71.1 Thu May 28 04:13 - 21:29 (17:16)
|
||||||
|
kbrazil pts/0 192.168.71.1 Wed May 27 16:09 - 04:13 (12:03)
|
||||||
|
root ttyv0 Wed May 27 12:48 still logged in
|
||||||
|
kbrazil pts/0 192.168.71.1 Wed May 27 12:47 - 16:09 (03:22)
|
||||||
|
kbrazil ttyv0 Wed May 27 12:46 - 12:48 (00:01)
|
||||||
|
boot time Wed May 27 12:46
|
||||||
|
|
||||||
|
utx.log begins Wed May 27 12:46:05 PDT 2020
|
@ -34,6 +34,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/last.out'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/last.out'), 'r', encoding='utf-8') as f:
|
||||||
self.fedora32_last = f.read()
|
self.fedora32_last = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/last.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.freebsd12_last = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/last.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/last.json'), 'r', encoding='utf-8') as f:
|
||||||
self.centos_7_7_last_json = json.loads(f.read())
|
self.centos_7_7_last_json = json.loads(f.read())
|
||||||
@ -59,6 +62,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/last.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/last.json'), 'r', encoding='utf-8') as f:
|
||||||
self.fedora32_last_json = json.loads(f.read())
|
self.fedora32_last_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/last.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.freebsd12_last_json = json.loads(f.read())
|
||||||
|
|
||||||
def test_last_centos_7_7(self):
|
def test_last_centos_7_7(self):
|
||||||
"""
|
"""
|
||||||
Test plain 'last' on Centos 7.7
|
Test plain 'last' on Centos 7.7
|
||||||
@ -107,6 +113,12 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.last.parse(self.fedora32_last, quiet=True), self.fedora32_last_json)
|
self.assertEqual(jc.parsers.last.parse(self.fedora32_last, quiet=True), self.fedora32_last_json)
|
||||||
|
|
||||||
|
def test_last_freebsd12(self):
|
||||||
|
"""
|
||||||
|
Test plain 'last' on FreeBSD12
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.last.parse(self.freebsd12_last, quiet=True), self.freebsd12_last_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user