From 2b2b570490f3834367a598579473001f45738e8a Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sat, 9 May 2020 11:22:26 -0700 Subject: [PATCH] add tests for 'gone - no logout' --- tests/fixtures/fedora32/last.json | 1 + tests/fixtures/fedora32/last.out | 8 ++++++++ tests/test_last.py | 12 ++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/fixtures/fedora32/last.json create mode 100644 tests/fixtures/fedora32/last.out diff --git a/tests/fixtures/fedora32/last.json b/tests/fixtures/fedora32/last.json new file mode 100644 index 00000000..6de2f767 --- /dev/null +++ b/tests/fixtures/fedora32/last.json @@ -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"}] diff --git a/tests/fixtures/fedora32/last.out b/tests/fixtures/fedora32/last.out new file mode 100644 index 00000000..45246c43 --- /dev/null +++ b/tests/fixtures/fedora32/last.out @@ -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 diff --git a/tests/test_last.py b/tests/test_last.py index dcd8b356..598eaed0 100644 --- a/tests/test_last.py +++ b/tests/test_last.py @@ -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()