[tests] Use temporary files for buildinstall
Instead of mocking open just write to the temporary file and then check its content. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
3ff1d3e21f
commit
c61abac137
@ -379,10 +379,8 @@ class BuildinstallThreadTestCase(PungiTestCase):
|
|||||||
|
|
||||||
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
||||||
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
||||||
@mock.patch('pungi.phases.buildinstall.open')
|
|
||||||
@mock.patch('pungi.phases.buildinstall.run')
|
@mock.patch('pungi.phases.buildinstall.run')
|
||||||
def test_buildinstall_thread_with_lorax_in_runroot(self, run, mock_open,
|
def test_buildinstall_thread_with_lorax_in_runroot(self, run, get_buildroot_rpms, KojiWrapperMock):
|
||||||
get_buildroot_rpms, KojiWrapperMock):
|
|
||||||
compose = BuildInstallCompose(self.topdir, {
|
compose = BuildInstallCompose(self.topdir, {
|
||||||
'buildinstall_method': 'lorax',
|
'buildinstall_method': 'lorax',
|
||||||
'runroot': True,
|
'runroot': True,
|
||||||
@ -414,16 +412,14 @@ class BuildinstallThreadTestCase(PungiTestCase):
|
|||||||
use_shell=True, task_id=True,
|
use_shell=True, task_id=True,
|
||||||
packages=['strace', 'lorax'], mounts=[self.topdir])])
|
packages=['strace', 'lorax'], mounts=[self.topdir])])
|
||||||
run_runroot_cmd(get_runroot_cmd.return_value, log_file='/log/buildinstall-Server.x86_64.log')
|
run_runroot_cmd(get_runroot_cmd.return_value, log_file='/log/buildinstall-Server.x86_64.log')
|
||||||
self.assertItemsEqual(
|
with open(self.topdir + '/logs/x86_64/buildinstall-Server-RPMs.x86_64.log') as f:
|
||||||
mock_open.return_value.write.mock_calls,
|
rpms = f.read().strip().split('\n')
|
||||||
[mock.call('bash\nzsh')])
|
self.assertItemsEqual(rpms, ['bash', 'zsh'])
|
||||||
|
|
||||||
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
||||||
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
||||||
@mock.patch('pungi.phases.buildinstall.open')
|
|
||||||
@mock.patch('pungi.phases.buildinstall.run')
|
@mock.patch('pungi.phases.buildinstall.run')
|
||||||
def test_buildinstall_thread_with_buildinstall_in_runroot(self, run, mock_open,
|
def test_buildinstall_thread_with_buildinstall_in_runroot(self, run, get_buildroot_rpms, KojiWrapperMock):
|
||||||
get_buildroot_rpms, KojiWrapperMock):
|
|
||||||
compose = BuildInstallCompose(self.topdir, {
|
compose = BuildInstallCompose(self.topdir, {
|
||||||
'buildinstall_method': 'buildinstall',
|
'buildinstall_method': 'buildinstall',
|
||||||
'runroot': True,
|
'runroot': True,
|
||||||
@ -456,16 +452,14 @@ class BuildinstallThreadTestCase(PungiTestCase):
|
|||||||
packages=['strace', 'anaconda'], mounts=[self.topdir])])
|
packages=['strace', 'anaconda'], mounts=[self.topdir])])
|
||||||
run_runroot_cmd(get_runroot_cmd.return_value,
|
run_runroot_cmd(get_runroot_cmd.return_value,
|
||||||
log_file=self.topdir + '/logs/buildinstall.x86_64.log')
|
log_file=self.topdir + '/logs/buildinstall.x86_64.log')
|
||||||
self.assertItemsEqual(
|
with open(self.topdir + '/logs/x86_64/buildinstall-RPMs.x86_64.log') as f:
|
||||||
mock_open.return_value.write.mock_calls,
|
rpms = f.read().strip().split('\n')
|
||||||
[mock.call('bash\nzsh')])
|
self.assertItemsEqual(rpms, ['bash', 'zsh'])
|
||||||
|
|
||||||
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
||||||
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
||||||
@mock.patch('pungi.phases.buildinstall.open')
|
|
||||||
@mock.patch('pungi.phases.buildinstall.run')
|
@mock.patch('pungi.phases.buildinstall.run')
|
||||||
def test_buildinstall_fail_exit_code(self, run, mock_open,
|
def test_buildinstall_fail_exit_code(self, run, get_buildroot_rpms, KojiWrapperMock):
|
||||||
get_buildroot_rpms, KojiWrapperMock):
|
|
||||||
compose = BuildInstallCompose(self.topdir, {
|
compose = BuildInstallCompose(self.topdir, {
|
||||||
'buildinstall_method': 'buildinstall',
|
'buildinstall_method': 'buildinstall',
|
||||||
'runroot': True,
|
'runroot': True,
|
||||||
@ -500,10 +494,8 @@ class BuildinstallThreadTestCase(PungiTestCase):
|
|||||||
|
|
||||||
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
||||||
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
||||||
@mock.patch('pungi.phases.buildinstall.open')
|
|
||||||
@mock.patch('pungi.phases.buildinstall.run')
|
@mock.patch('pungi.phases.buildinstall.run')
|
||||||
def test_lorax_fail_exit_code(self, run, mock_open,
|
def test_lorax_fail_exit_code(self, run, get_buildroot_rpms, KojiWrapperMock):
|
||||||
get_buildroot_rpms, KojiWrapperMock):
|
|
||||||
compose = BuildInstallCompose(self.topdir, {
|
compose = BuildInstallCompose(self.topdir, {
|
||||||
'buildinstall_method': 'lorax',
|
'buildinstall_method': 'lorax',
|
||||||
'runroot': True,
|
'runroot': True,
|
||||||
|
Loading…
Reference in New Issue
Block a user