# Path: ubuntucleaner/utils/system.py
# def get_codename():
#     return os.popen('lsb_release -cs').read().strip()
# 
# def get_desktop():
#     '''
#     ubuntu
#     ubuntu-2d
#     gnome-classic
#     gnome-shell
#     '''
#     return os.getenv('DESKTOP_SESSION')
# 
# def get_distro():
#     return os.popen('lsb_release -ds').read().strip()


import unittest
import mock
from ubuntucleaner.utils.system import get_codename, get_desktop, get_distro



def patch_load_icon(side_effect=None):
    return mock.patch(
        "ubuntucleaner.utils.icon.Gtk.IconTheme.load_icon",
        side_effect=side_effect)


def patch_log():
    return mock.patch("ubuntucleaner.utils.icon.log")


def patch_get_from_name():
    return mock.patch("ubuntucleaner.utils.icon.get_from_name")


class TestSystemModule(unittest.TestCase):

    def test_get_distro(self):
        with mock.patch("ubuntucleaner.utils.system.os.popen") as m_popen:
            m_popen.return_value.read.return_value = 'Ubuntu 18.04.4 LTS\n'

# Path: ubuntucleaner/utils/system.py
# def get_codename():
#     return os.popen('lsb_release -cs').read().strip()
# 
# def get_desktop():
#     '''
#     ubuntu
#     ubuntu-2d
#     gnome-classic
#     gnome-shell
#     '''
#     return os.getenv('DESKTOP_SESSION')
# 
# def get_distro():
#     return os.popen('lsb_release -ds').read().strip()


# Path: tests/utils/test_system.py
import unittest
import mock
from ubuntucleaner.utils.system import get_codename, get_desktop, get_distro




def patch_load_icon(side_effect=None):
    return mock.patch(
        "ubuntucleaner.utils.icon.Gtk.IconTheme.load_icon",
        side_effect=side_effect)


def patch_log():
    return mock.patch("ubuntucleaner.utils.icon.log")


def patch_get_from_name():
    return mock.patch("ubuntucleaner.utils.icon.get_from_name")


class TestSystemModule(unittest.TestCase):

    def test_get_distro(self):
        with mock.patch("ubuntucleaner.utils.system.os.popen") as m_popen:
            m_popen.return_value.read.return_value = 'Ubuntu 18.04.4 LTS\n'

            distro = get_distro()