def test_initial_values(self, load_avg_mock, cpu_count_mock): cpu_count_mock.return_value = 1 load_avg_mock.return_value = (0.10, 0.20, 0.30) module = build_module() assert widget(module).full_text() == '0.00/0.00/0.00'
def test_public_ip_with_exception(self, public_ip_mock): public_ip_mock.side_effect = Exception module = build_module() module.update() assert widget(module).full_text() == 'n/a'
def test_public_ip(self, public_ip_mock): public_ip_mock.return_value = None module = build_module() module.update() assert widget(module).full_text() == 'n/a'
def test_healthy_state_with_8_cpus(self, load_avg_mock, cpu_count_mock): cpu_count_mock.return_value = 8 load_avg_mock.return_value = (4.42, 0.85, 0.9) module = build_module() module.update() assert module.state(widget(module)) == None
def test_critical_state(self, load_avg_mock, cpu_count_mock): cpu_count_mock.return_value = 1 load_avg_mock.return_value = (0.95, 0.85, 0.9) module = build_module() module.update() assert module.state(widget(module)) == 'critical'
def test_healthy_state(self, load_avg_mock, cpu_count_mock): cpu_count_mock.return_value = 1 load_avg_mock.return_value = (0.55, 0.95, 0.25) module = build_module() module.update() assert module.state(widget(module)) == None
def test_cpu_count_exception(self, load_avg_mock, cpu_count_mock): cpu_count_mock.side_effect = NotImplementedError load_avg_mock.return_value = (0.1, 0.2, 0.3) module = build_module() module.update() assert widget(module).full_text() == '0.10/0.20/0.30'
def test_update_values(self, load_avg_mock, cpu_count_mock): cpu_count_mock.return_value = 1 load_avg_mock.return_value = (0.85, 0.95, 0.25) module = build_module() module.update() assert widget(module).full_text() == '0.85/0.95/0.25'
def test_warning_state_with_8_cpus(self, load_avg_mock, cpu_count_mock): cpu_count_mock.return_value = 8 load_avg_mock.return_value = (5.65, 0.85, 0.9) module = build_module() module.update() assert module.state(widget(module)) == 'warning'
def test_uptime(self, uptime_mock): module = build_module() module.update() uptime_mock.assert_called_with('/proc/uptime', 'r') assert widget(module).full_text() == '3 days, 11:20:00'