def setup(self, tmpdir, monkeypatch): '''Run this before every test invocation''' self.artifactsdir = tmpdir.mkdir('artifacts') self.taskdir = tmpdir.mkdir('taskdir') self.client_taskdir = tmpdir.mkdir('client_taskdir') self.arg_data = { 'artifactsdir': self.artifactsdir.strpath, 'taskdir': self.taskdir.strpath, 'item': 'htop-2.0.2-4.fc27', 'type': 'koji_build', 'arch': 'noarch', 'debug': False, 'local': True, 'libvirt': False, 'ssh': False, 'ssh_privkey': None, } self.playbook_name = 'tests.yml' self.playbook = self.taskdir.join(self.playbook_name) self.playbook.write(PLAYBOOK) self.ipaddr = '127.0.0.1' self.executor = executor.Executor(self.arg_data) self.playbook_vars = self.executor._create_playbook_vars( self.playbook_name) monkeypatch.setattr(config, '_config', None) self.conf = config.get_config() self.conf.client_taskdir = self.client_taskdir.strpath
def test_get_client_ipaddr_libvirt(self): '''Libvirt execution''' self.arg_data['local'] = False self.arg_data['libvirt'] = True self.arg_data['ssh'] = False self.executor = executor.Executor(self.arg_data) ipaddr = self.executor._get_client_ipaddr() assert ipaddr == None assert self.executor.run_remotely == True
def test_get_client_ipaddr_ssh(self): '''Ssh execution''' self.arg_data['local'] = False self.arg_data['libvirt'] = False self.arg_data['ssh'] = True self.arg_data['machine'] = '127.0.0.2' self.executor = executor.Executor(self.arg_data) ipaddr = self.executor._get_client_ipaddr() assert ipaddr == '127.0.0.2' assert self.executor.run_remotely == True