/
githubmirror
/
salt
Обзор
Документация
Войти
/
githubmirror
/
salt
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/integration/states/test_host.py
53 строки
1 KB
Pedro Algarvio
Update pre-commit hook versions
29 фев 2024, 15:30
Не верифицирован
29 фев 2024, 15:30
f454911
Код
Авторство
О чём код?
""" tests for host state """ import logging import os import shutil import pytest import salt.utils.files import salt.utils.stringutils from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin from tests.support.runtests import RUNTIME_VARS log = logging.getLogger(__name__) @pytest.mark.windows_whitelisted class HostTest(ModuleCase, SaltReturnAssertsMixin): """ Validate the host state """ @classmethod def setUpClass(cls): cls.hosts_file = os.path.join(RUNTIME_VARS.TMP, "hosts") def __clear_hosts(self): """ Delete the tmp hosts file """ if os.path.isfile(self.hosts_file): os.remove(self.hosts_file) def setUp(self): shutil.copyfile(os.path.join(RUNTIME_VARS.FILES, "hosts"), self.hosts_file) self.addCleanup(self.__clear_hosts) super().setUp() @pytest.mark.slow_test def test_present(self): """ host.present """ name = "spam.bacon" ip = "10.10.10.10" ret = self.run_state("host.present", name=name, ip=ip) self.assertSaltTrueReturn(ret) with salt.utils.files.fopen(self.hosts_file) as fp_: output = salt.utils.stringutils.to_unicode(fp_.read()) self.assertIn(f"{ip}\t\t{name}", output)