def _get_local_hdd_info_gb(): path = pathutils.instance_dir(action=constants.PATH_CREATE) drive = os.path.splitdrive(path)[0] or path usage = hostutils.disk_usage(drive) total_gb = usage.total / units.Gi free_gb = usage.free / units.Gi used_gb = usage.used / units.Gi return (total_gb, free_gb, used_gb)
def test_instance_dir(self, mock_join): pathutils.instance_dir() self.assertEqual(1, mock_join.call_count)
def test_action(self, mock_create, mock_delete, mock_exists): path = pathutils.instance_dir() pathutils.instance_dir(action=mock.sentinel.invalid_action) self.assertEqual(0, mock_create.call_count) self.assertEqual(0, mock_delete.call_count) self.assertEqual(0, mock_exists.call_count) pathutils.instance_dir(action=constants.PATH_CREATE) mock_create.assert_called_once_with(path) mock_create.reset_mock() pathutils.instance_dir(action=constants.PATH_DELETE) mock_delete.assert_called_once_with(path) mock_delete.reset_mock() pathutils.instance_dir(action=constants.PATH_EXISTS) mock_exists.assert_called_once_with(path) mock_exists.reset_mock() pathutils.instance_dir(action=constants.PATH_OVERWRITE) mock_delete.assert_called_once_with(path) mock_create.assert_called_once_with(path)