def test_set_logging(self): _m_set_logging = Mock() # Called after mount() v = Volume("host", "vol") with patch("gluster.gfapi.api.glfs_set_logging", _m_set_logging): v.mount() v.set_logging("/path/whatever", 7) self.assertEqual(v.log_file, "/path/whatever") self.assertEqual(v.log_level, 7)
def test_set_logging(self): # Create volume object instance vol = Volume(HOST, VOLNAME) # Call set_logging before mount() log_file = "/tmp/%s" % (uuid4().hex) vol.set_logging(log_file, 7) # Mount the volume vol.mount() self.assertTrue(vol.mounted) self.assertEqual(vol.log_file, log_file) self.assertEqual(vol.log_level, 7) # Check that log has been created and exists self.assertTrue(os.path.exists(log_file)) # Change the logging after mounting log_file2 = "/tmp/%s" % (uuid4().hex) vol.set_logging(log_file2, 7) self.assertEqual(vol.log_file, log_file2) # Unmount the volume vol.umount() self.assertFalse(vol.mounted)