mirror of
https://github.com/certbot/certbot.git
synced 2026-04-28 17:51:04 -04:00
Tests
This commit is contained in:
parent
63a47f8b6b
commit
093ebd2f03
3 changed files with 27 additions and 1 deletions
|
|
@ -25,3 +25,20 @@ class ConstantsTest(unittest.TestCase):
|
|||
os_info.return_value = ('Nonexistent Linux', '', '')
|
||||
self.assertEqual(constants.os_constant("vhost_root"),
|
||||
"/etc/apache2/sites-available")
|
||||
|
||||
@mock.patch("certbot.util.get_os_info")
|
||||
def test_get_default_constants(self, os_info):
|
||||
os_info.return_value = ('Nonexistent Linux', '', '')
|
||||
with mock.patch("certbot.util.get_systemd_os_like") as os_like:
|
||||
# Get defaults
|
||||
os_like.return_value = False
|
||||
c_hm = constants.os_constant("handle_mods")
|
||||
c_sr = constants.os_constant("server_root")
|
||||
self.assertFalse(c_hm)
|
||||
self.assertEqual(c_sr, "/etc/apache2")
|
||||
# Use darwin as like test target
|
||||
os_like.return_value = ["something", "nonexistent", "darwin"]
|
||||
d_vr = constants.os_constant("vhost_root")
|
||||
d_em = constants.os_constant("enmod")
|
||||
self.assertFalse(d_em)
|
||||
self.assertEqual(d_vr, "/etc/apache2/other")
|
||||
|
|
|
|||
2
certbot/tests/testdata/os-release
vendored
2
certbot/tests/testdata/os-release
vendored
|
|
@ -1,7 +1,7 @@
|
|||
NAME="SystemdOS"
|
||||
VERSION="42.42.42 LTS, Unreal"
|
||||
ID=systemdos
|
||||
ID_LIKE=debian
|
||||
ID_LIKE="something nonexistent debian"
|
||||
VERSION_ID="42"
|
||||
HOME_URL="http://www.example.com/"
|
||||
SUPPORT_URL="http://help.example.com/"
|
||||
|
|
|
|||
|
|
@ -359,6 +359,15 @@ class OsInfoTest(unittest.TestCase):
|
|||
with mock.patch('os.path.isfile', return_value=False):
|
||||
self.assertEqual(get_systemd_os_info(), ("", ""))
|
||||
|
||||
def test_systemd_os_release_like(self):
|
||||
from certbot.util import get_systemd_os_like
|
||||
|
||||
with mock.patch('os.path.isfile', return_value=True):
|
||||
id_likes = get_systemd_os_like(test_util.vector_path(
|
||||
"os-release"))
|
||||
self.assertEqual(len(id_likes), 3)
|
||||
self.assertTrue("debian" in id_likes)
|
||||
|
||||
@mock.patch("certbot.util.subprocess.Popen")
|
||||
def test_non_systemd_os_info(self, popen_mock):
|
||||
from certbot.util import (get_os_info, get_python_os_info,
|
||||
|
|
|
|||
Loading…
Reference in a new issue