from unittest import TestCase
import unittest
import logging
import opcache_checker
import os.path

current_path = os.path.dirname(os.path.abspath(__file__))
test_path = os.path.join(current_path, "..", "test", "opcache_checker")


class TestOpcacheChecker(TestCase):
    def test_check_normal(self):
        checker = opcache_checker.OpcacheChecker(
            logging.getLogger(),
            os.path.join(test_path, "unzip"),
            os.path.join(test_path, "install1"),
        )
        self.assertTrue(checker.check())

    def test_check_file_not_exists(self):
        checker = opcache_checker.OpcacheChecker(
            logging.getLogger(),
            os.path.join(test_path, "unzip"),
            os.path.join(test_path, "install2"),
        )
        self.assertFalse(checker.check())

    def test_check_file_modified(self):
        checker = opcache_checker.OpcacheChecker(
            logging.getLogger(),
            os.path.join(test_path, "unzip"),
            os.path.join(test_path, "install3"),
        )
        self.assertFalse(checker.check())

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