def test_get_uptime_uptime2(): ut = Uptime(context_wrap(UPTIME2)) upt = uptime(ut, None) assert upt.currtime == '10:55:22' assert upt.updays == '40' assert upt.uphhmm == '00:03' assert upt.users == '1' assert upt.loadavg == ['0.49', '0.12', '0.04'] c = datetime.timedelta(days=40, hours=0, minutes=3) assert total_seconds(upt.uptime) == total_seconds(c)
def test_get_uptimes(): for test_data in UPTIME_TEST_DATA: uptime = Uptime(context_wrap(test_data['test_data'])) assert len(uptime.data) == 6 assert uptime.currtime == test_data['currtime'] assert uptime.updays == test_data['updays'] assert uptime.uphhmm == test_data['uphhmm'] assert uptime.users == test_data['users'] assert uptime.loadavg == test_data['loadavg'] assert total_seconds(uptime.uptime) == total_seconds(test_data['uptime'])
def test_get_uptime_uptime1(): ut = Uptime(context_wrap(UPTIME1)) upt = uptime(ut, None) assert upt.currtime == '14:28:24' assert upt.updays == "" assert upt.uphhmm == '5:55' assert upt.users == '4' assert upt.loadavg == ['0.04', '0.03', '0.05'] c = datetime.timedelta(days=0, hours=5, minutes=55) assert total_seconds(upt.uptime) == total_seconds(c)
def test_get_no_uptime(): with pytest.raises(ParseException) as exc: uptime = Uptime(context_wrap(NOT_AN_UPTIME)) assert len(uptime.data) == 0 assert 'No uptime data found on ' in str(exc)