def test_clean(self):
     mc = MockChroot(root='epel-6-x86_64')
     expected = 'testing\n'
     output = mc.chroot('bash', '-c', 'echo testing | tee test.txt')
     assert output == expected
     output = mc.chroot('cat', 'test.txt')
     assert output == expected
     mc.clean()
     with pytest.raises(CalledProcessError):
         output = mc.chroot('cat', 'test.txt')
     expected = 'not there\n'
     output = mc.chroot('bash', '-c', 'test -e test.txt || echo not there')
     assert output == expected
 def test_clean(self):
     mc = MockChroot(root='epel-6-x86_64')
     expected = 'testing\n'
     output = mc.chroot('bash', '-c', 'echo testing | tee test.txt')
     assert output == expected
     output = mc.chroot('cat', 'test.txt')
     assert output == expected
     mc.clean()
     with pytest.raises(CalledProcessError):
         output = mc.chroot('cat', 'test.txt')
     expected = 'not there\n'
     output = mc.chroot('bash', '-c', 'test -e test.txt || echo not there')
     assert output == expected
 def test_chroot(self):
     mc = MockChroot(root='epel-6-x86_64')
     expected = 'CentOS release 6.7 (Final)\nKernel \\r on an \\m\n\n'
     output = mc.chroot('cat', '/etc/issue')
     assert output == expected
     expected = 'testing\n'
     output = mc.chroot('bash', '-c', 'echo testing | tee test.txt')
     assert output == expected
     output = mc.chroot('cat', 'test.txt')
     assert output == expected
     with pytest.raises(CalledProcessError):
         output = mc.chroot('false')
     # the following will raise an exception if we're in the wrong directory
     output = mc.chroot('cat', 'hosts', cwd='etc')
 def test_chroot(self):
     mc = MockChroot(root='epel-6-x86_64')
     expected = 'CentOS release 6.7 (Final)\nKernel \\r on an \\m\n\n'
     output = mc.chroot('cat', '/etc/issue')
     assert output == expected
     expected = 'testing\n'
     output = mc.chroot('bash', '-c', 'echo testing | tee test.txt')
     assert output == expected
     output = mc.chroot('cat', 'test.txt')
     assert output == expected
     with pytest.raises(CalledProcessError):
         output = mc.chroot('false')
     # the following will raise an exception if we're in the wrong directory
     output = mc.chroot('cat', 'hosts', cwd='etc')
 def test_string_config(self, custom_mock_cfg):
     cmc = MockChroot(config=custom_mock_cfg)
     output = cmc.chroot('/usr/bin/yum', '-q', 'list', 'google-chrome-beta')
     # If the package is not there, or any other error, yum will return a
     # nonzero value, which will raise an exception. So output will contain a
     # non blank string only if the package is found
     assert output
 def test_chroot_by_target(self):
     mc = MockChroot(config=from_koji(
         target='rhevm-3.5-rhel-6-mead-candidate'))
     expected = ('Red Hat Enterprise Linux Server release 6.3 Beta '
                 '(Santiago)\nKernel \\r on an \\m\n\n')
     output = mc.chroot('cat', '/etc/issue')
     assert output == expected
 def test_string_config(self, custom_mock_cfg):
     cmc = MockChroot(config=custom_mock_cfg)
     output = cmc.chroot('/usr/bin/yum', '-q', 'list', 'google-chrome-beta')
     # If the package is not there, or any other error, yum will return a
     # nonzero value, which will raise an exception. So output will contain a
     # non blank string only if the package is found
     assert output
Exemplo n.º 8
0
 def test_bind_mount(self, custom_mock_cfg, dir_to_mount):
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg, mock_chroot.config.bind_mount(
             dir_to_mount['pair'])))
     output = cmc.chroot('cat', dir_to_mount['test_file_path'])
     # If we got here, we've no exception so the file is there
     assert output
Exemplo n.º 9
0
 def test_use_host_resolv(self, custom_mock_cfg):
     host_name = 'www.google.com'
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg, mock_chroot.config.use_host_resolv()))
     output = cmc.chroot('getent', 'hosts', host_name)
     # If we got here, we've no exception so DNS worked
     assert output
 def test_chroot_by_tag(self):
     mc = MockChroot(config=from_koji(tag='rhevm-3.5-rhel-6-mead-build'))
     expected = (
         'Red Hat Enterprise Linux Server release 6.3 Beta '
         '(Santiago)\nKernel \\r on an \\m\n\n'
     )
     output = mc.chroot('cat', '/etc/issue')
     assert output == expected
 def test_bind_mount(self, custom_mock_cfg, dir_to_mount):
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg,
         mock_chroot.config.bind_mount(dir_to_mount['pair'])
     ))
     output = cmc.chroot('cat', dir_to_mount['test_file_path'])
     # If we got here, we've no exception so the file is there
     assert output
Exemplo n.º 12
0
 def test_env_vars(self, custom_mock_cfg):
     var_name = 'MY_VAR'
     var_value = 'my value'
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg,
         mock_chroot.config.env_vars(**{var_name: var_value})))
     output = cmc.chroot('bash', '-c', 'echo "${0}"'.format(var_name))
     # If we got here, we've no exception so the file is there
     assert output.rstrip() == var_value
 def test_use_host_resolv(self, custom_mock_cfg):
     host_name = 'www.google.com'
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg,
         mock_chroot.config.use_host_resolv()
     ))
     output = cmc.chroot('getent', 'hosts', host_name)
     # If we got here, we've no exception so DNS worked
     assert output
Exemplo n.º 14
0
 def test_file(self, custom_mock_cfg):
     file_path = '/a_generated_file.txt'
     file_content = 'just some generated text'
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg, mock_chroot.config.file(file_path, file_content)))
     # Must clean the chroot for files to be created
     cmc.clean()
     output = cmc.chroot('cat', file_path)
     # If we got here, we've no exception so the file is there
     assert output == file_content
 def test_env_vars(self, custom_mock_cfg):
     var_name = 'MY_VAR'
     var_value = 'my value'
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg,
         mock_chroot.config.env_vars(**{var_name: var_value})
     ))
     output = cmc.chroot('bash', '-c', 'echo "${0}"'.format(var_name))
     # If we got here, we've no exception so the file is there
     assert output.rstrip() == var_value
 def test_file(self, custom_mock_cfg):
     file_path = '/a_generated_file.txt'
     file_content = 'just some generated text'
     cmc = MockChroot(config=mock_chroot.config.compose(
         custom_mock_cfg,
         mock_chroot.config.file(file_path, file_content)
     ))
     # Must clean the chroot for files to be created
     cmc.clean()
     output = cmc.chroot('cat', file_path)
     # If we got here, we've no exception so the file is there
     assert output == file_content