# Path: qpanel/upgrader.py
# def __first_line(content):
#     tmp = ''
#     if content is not None:
#         tmp = content.splitlines()
#     if len(tmp) >= 1:
#         return tmp[0]
#     return tmp
# 
# def get_current_version():
#     return qpanel.__version__
# 
# def check_require_upgrade(current, stable):
#     a = LooseVersion(current)
#     b = LooseVersion(stable)
#     if a < b:
#         return True
#     return False
# 
# def get_stable_version(url=URL_STABLE_VERSION):
#     stable_version = __get_data_url(url)
#     return __first_line(stable_version)


import shutil
import tempfile
import unittest
import qpanel
from qpanel.upgrader import (__first_line as firstline,
    get_current_version, check_require_upgrade, get_stable_version)


class UpgradeTestClass(unittest.TestCase):

    def setUp(self):
        # Create a temporary directory
        self.test_dir = tempfile.mkdtemp()

    def tearDown(self):
        # Remove the directory after the test
        shutil.rmtree(self.test_dir)

    def test_first_line(self):
        content = 'a\n\b\t\b'
        self.assertEqual(firstline(content), 'a')

# Path: qpanel/upgrader.py
# def __first_line(content):
#     tmp = ''
#     if content is not None:
#         tmp = content.splitlines()
#     if len(tmp) >= 1:
#         return tmp[0]
#     return tmp
# 
# def get_current_version():
#     return qpanel.__version__
# 
# def check_require_upgrade(current, stable):
#     a = LooseVersion(current)
#     b = LooseVersion(stable)
#     if a < b:
#         return True
#     return False
# 
# def get_stable_version(url=URL_STABLE_VERSION):
#     stable_version = __get_data_url(url)
#     return __first_line(stable_version)


# Path: tests/test_upgrade.py
import shutil
import tempfile
import unittest
import qpanel
from qpanel.upgrader import (__first_line as firstline,
    get_current_version, check_require_upgrade, get_stable_version)



class UpgradeTestClass(unittest.TestCase):

    def setUp(self):
        # Create a temporary directory
        self.test_dir = tempfile.mkdtemp()

    def tearDown(self):
        # Remove the directory after the test
        shutil.rmtree(self.test_dir)

    def test_first_line(self):
        content = 'a\n\b\t\b'
        self.assertEqual(firstline(content), 'a')

        self.assertNotEqual(firstline(content), 'ab')