# /*
#  * Copyright (C) 2020, KylinSoft Co., Ltd.
#  *
#  * This program is free software: you can redistribute it and/or modify
#  * it under the terms of the GNU General Public License as published by
#  * the Free Software Foundation, either version 3 of the License, or
#  * (at your option) any later version.
#  *
#  * This program is distributed in the hope that it will be useful,
#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  * GNU General Public License for more details.
#  *
#  * You should have received a copy of the GNU General Public License
#  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
#  */

import unittest
import sys
import os
from SystemUpdater.Core.errors import *

# 配置 logging 输出到终端,方便调试
logging.basicConfig(
    level=logging.DEBUG,
    format='[%(asctime)s] %(levelname)s:%(name)s: %(message)s',
    stream=sys.stdout
)
logger = logging.getLogger(__name__)

# 添加项目根目录到 sys.path
from SystemUpdater.Core.diskManager import check_free_space
class TestCalculator(unittest.TestCase):
    # def test_diskManagerClassInit(self):
        # testclass = diskManager()
        # self.assertIsInstance(testclass, diskManager)

    def test_spaceCheckTrue(self):
        result = check_free_space(200*1024,200*1024)
        self.assertEqual(True, result)

    def test_spaceCheckFalse(self):
        with self.assertRaises(UpdateBaseError):
            result = check_free_space(9999999999999999,100000)

    def test_spaceCheckaddis0(self):
        result = check_free_space(100000)
        self.assertEqual(True, result)
    
    def test_spaceCheckaddnotis0(self):
        with self.assertRaises(UpdateBaseError):
            result = check_free_space(9999999999999999)
    def test_spaceCheckaddnotis1(self):
        with self.assertRaises(UpdateBaseError):
            result = check_free_space(69506341376)

if __name__ == "__main__":
    unittest.main()