[ Avaa Bypassed ]




Upload:

Command:

www-data@3.141.18.167: ~ $
"""Test for certbot_apache.entrypoint for override class resolution"""
import unittest

import mock

from certbot_apache import configurator
from certbot_apache import entrypoint


class EntryPointTest(unittest.TestCase):
    """Entrypoint tests"""

    _multiprocess_can_split_ = True

    def test_get_configurator(self):

        with mock.patch("certbot.util.get_os_info") as mock_info:
            for distro in entrypoint.OVERRIDE_CLASSES:
                return_value = (distro, "whatever")
                if distro == 'fedora_old':
                    return_value = ('fedora', '28')
                elif distro == 'fedora':
                    return_value = ('fedora', '29')
                mock_info.return_value = return_value
                self.assertEqual(entrypoint.get_configurator(),
                                 entrypoint.OVERRIDE_CLASSES[distro])

    def test_nonexistent_like(self):
        with mock.patch("certbot.util.get_os_info") as mock_info:
            mock_info.return_value = ("nonexistent", "irrelevant")
            with mock.patch("certbot.util.get_systemd_os_like") as mock_like:
                for like in entrypoint.OVERRIDE_CLASSES:
                    mock_like.return_value = [like]
                    self.assertEqual(entrypoint.get_configurator(),
                                     entrypoint.OVERRIDE_CLASSES[like])

    def test_nonexistent_generic(self):
        with mock.patch("certbot.util.get_os_info") as mock_info:
            mock_info.return_value = ("nonexistent", "irrelevant")
            with mock.patch("certbot.util.get_systemd_os_like") as mock_like:
                mock_like.return_value = ["unknonwn"]
                self.assertEqual(entrypoint.get_configurator(),
                                 configurator.ApacheConfigurator)


if __name__ == "__main__":
    unittest.main()  # pragma: no cover

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 27 B 0644
autohsts_test.py File 8.81 KB 0644
centos6_test.py File 9.5 KB 0644
centos_test.py File 8.24 KB 0644
complex_parsing_test.py File 4.45 KB 0644
configurator_reverter_test.py File 2.76 KB 0644
configurator_test.py File 75.32 KB 0644
debian_test.py File 8.93 KB 0644
display_ops_test.py File 3.64 KB 0644
entrypoint_test.py File 1.83 KB 0644
fedora_test.py File 8.18 KB 0644
gentoo_test.py File 5.53 KB 0644
http_01_test.py File 9.13 KB 0644
obj_test.py File 5.22 KB 0644
parser_test.py File 16.2 KB 0644
util.py File 10.5 KB 0644