1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-08 22:36:48 +02:00

add tests for 'gone - no logout'

This commit is contained in:
Kelly Brazil
2020-05-09 11:22:26 -07:00
parent cce2d1ff29
commit 2b2b570490
3 changed files with 21 additions and 0 deletions

1
tests/fixtures/fedora32/last.json vendored Normal file
View File

@ -0,0 +1 @@
[{"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Fri May 1 15:25", "logout": "gone - no logout"}, {"user": "kbrazil", "tty": "tty1", "hostname": null, "login": "Fri May 1 15:24", "logout": "gone - no logout"}, {"user": "reboot", "tty": "system boot", "hostname": "5.6.6-300.fc32.x", "login": "Fri May 1 15:24", "logout": "running"}, {"user": "kbrazil", "tty": "pts/0", "hostname": "192.168.71.1", "login": "Thu Apr 30 15:27", "logout": "15:22", "duration": "23:55"}, {"user": "kbrazil", "tty": "tty1", "hostname": null, "login": "Thu Apr 30 15:25", "logout": "down", "duration": "23:57"}, {"user": "reboot", "tty": "system boot", "hostname": "5.6.6-300.fc32.x", "login": "Thu Apr 30 15:22", "logout": "15:22", "duration": "1+00:00"}]

8
tests/fixtures/fedora32/last.out vendored Normal file
View File

@ -0,0 +1,8 @@
kbrazil pts/0 192.168.71.1 Fri May 1 15:25 gone - no logout
kbrazil tty1 Fri May 1 15:24 gone - no logout
reboot system boot 5.6.6-300.fc32.x Fri May 1 15:24 still running
kbrazil pts/0 192.168.71.1 Thu Apr 30 15:27 - 15:22 (23:55)
kbrazil tty1 Thu Apr 30 15:25 - down (23:57)
reboot system boot 5.6.6-300.fc32.x Thu Apr 30 15:22 - 15:22 (1+00:00)
wtmp begins Thu Apr 30 15:22:02 2020

View File

@ -31,6 +31,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/last-w.out'), 'r', encoding='utf-8') as f:
self.ubuntu_18_4_last_w = f.read()
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()
# output
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())
@ -53,6 +56,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/last-w.json'), 'r', encoding='utf-8') as f:
self.ubuntu_18_4_last_w_json = json.loads(f.read())
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())
def test_last_centos_7_7(self):
"""
Test plain 'last' on Centos 7.7
@ -95,6 +101,12 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.last.parse(self.ubuntu_18_4_last_w, quiet=True), self.ubuntu_18_4_last_w_json)
def test_last_fedora32(self):
"""
Test plain 'last' on Fedora32
"""
self.assertEqual(jc.parsers.last.parse(self.fedora32_last, quiet=True), self.fedora32_last_json)
if __name__ == '__main__':
unittest.main()