def test_DiskSpace_free(self): # Hopefully our test machine has at least 1 byte free on / config_options = {"partition": "/", "limit": "1"} m = host.MonitorDiskSpace("test", config_options) m.run_test() self.assertTrue(m.test_success()) # and hopefully it has a sensible-sized root partition config_options = {"partition": "/", "limit": "100000G"} m = host.MonitorDiskSpace("test", config_options) m.run_test() self.assertFalse(m.test_success())
def test_DiskSpace_invalid_partition(self): config_options = {"partition": "moo", "limit": "1"} m = host.MonitorDiskSpace("test", config_options) m.run_test() self.assertFalse(m.test_success(), "Monitor did not fail") self.assertRegex( m.last_result, "Couldn't get free disk space", "Monitor did not report error correctly", )
def test_DiskSpace_meta(self): m = host.MonitorDiskSpace("test", self.safe_config) self.assertEqual( m.describe(), "Checking for at least 10.00GiB free space on /", "Failed to verify description", ) self.assertTupleEqual(m.get_params(), (10 * self.one_GB, "/"), "Failed to verify params")
def test_DiskSpace_correctConfig(self): m = host.MonitorDiskSpace("test", self.safe_config) self.assertIsInstance(m, host.MonitorDiskSpace)
def test_DiskSpace_brokenConfigThree(self): config_options = {"partition": "/", "limit": "moo"} with self.assertRaises(ValueError): host.MonitorDiskSpace("test", config_options)
def test_DiskSpace_brokenConfigTwo(self): config_options = {"partition": "/"} with self.assertRaises(MonitorConfigurationError): host.MonitorDiskSpace("test", config_options)
def test_DiskSpace_brokenConfigOne(self): config_options = {} with self.assertRaises(MonitorConfigurationError): host.MonitorDiskSpace("test", config_options)
def test_DiskSpace_get_params(self): config_options = {"partition": "/", "limit": "1"} m = host.MonitorDiskSpace("test", config_options) self.assertTupleEqual(m.get_params(), (1, "/"))