From ce0f1884e17e8a0a92cea2ead48bed07013734da Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Jan 12 2017 19:28:22 +0000 Subject: update tests --- diff --git a/tests/test_tasks.py b/tests/test_tasks.py index 6fc50a6..c85a689 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -1,14 +1,15 @@ import random +from io import StringIO +from os import path, makedirs +from shutil import rmtree +from tempfile import gettempdir from unittest import TestCase from mock import patch, Mock, call -from tempfile import gettempdir -from shutil import rmtree -from os import path, makedirs -from io import StringIO import koji -from koji.tasks import scan_mounts, umount_all, safe_rmtree, BaseTaskHandler, FakeTask, SleepTask, ForkTask -from koji import BuildError, GenericError +from koji.tasks import BaseTaskHandler, FakeTask, ForkTask, SleepTask,\ + scan_mounts, umount_all, safe_rmtree + def get_fake_mounts_file(): """ Returns contents of /prc/mounts in a file-like object @@ -271,7 +272,7 @@ class TasksTestCase(TestCase): obj.session.host.taskWaitResults.return_value = taskWaitResults self.assertEquals(obj.wait([1551234, 1591234]), dict(taskWaitResults)) obj.session.host.taskSetWait.assert_called_once_with(12345678, [1551234, 1591234]) - obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234]) + obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234], canfail=[]) def test_BaseTaskHandler_wait_some_not_done(self): """ Tests that the wait function returns the one finished subtask results of @@ -296,7 +297,7 @@ class TasksTestCase(TestCase): obj.session.host.taskWaitResults.return_value = taskWaitResults self.assertEquals(obj.wait([1551234, 1591234]), dict(taskWaitResults)) obj.session.host.taskSetWait.assert_called_once_with(12345678, [1551234, 1591234]) - obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234]) + obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234], canfail=[]) @patch('signal.pause', return_value=None) def test_BaseTaskHandler_wait_some_not_done_all_set(self, mock_signal_pause): @@ -336,7 +337,7 @@ class TasksTestCase(TestCase): obj.session.host.taskSetWait.assert_called_once_with(12345678, [1551234, 1591234]) obj.session.host.taskWait.assert_has_calls([call(12345678), call(12345678)]) mock_signal_pause.assert_called_once_with() - obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234]) + obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234], canfail=[]) def test_BaseTaskHandler_wait_some_not_done_all_set_failany_set_failed_task(self): """ Tests that the wait function raises an exception when one of the subtask fails when the failany flag is set @@ -348,11 +349,11 @@ class TasksTestCase(TestCase): obj.session = Mock() obj.session.host.taskSetWait.return_value = None obj.session.host.taskWait.side_effect = [[[1551234], [1591234]], [[1551234, 1591234], []]] - obj.session.getTaskResult.side_effect = GenericError('Uh oh, we\'ve got a problem here!') + obj.session.getTaskResult.side_effect = koji.GenericError('Uh oh, we\'ve got a problem here!') try: obj.wait([1551234, 1591234], all=True, failany=True) raise Exception('A GeneralError was not raised.') - except GenericError as e: + except koji.GenericError as e: self.assertEquals(e.message, 'Uh oh, we\'ve got a problem here!') obj.session.host.taskSetWait.assert_called_once_with(12345678, [1551234, 1591234]) @@ -509,7 +510,7 @@ class TasksTestCase(TestCase): try: obj.find_arch('noarch', host, None) raise Exception('The BuildError Exception was not raised') - except BuildError as e: + except koji.BuildError as e: self.assertEquals(e.message, 'No arch list for this host: test.domain.local') def test_BaseTaskHandler_find_arch_noarch_bad_tag(self): @@ -524,7 +525,7 @@ class TasksTestCase(TestCase): try: obj.find_arch('noarch', host, tag) raise Exception('The BuildError Exception was not raised') - except BuildError as e: + except koji.BuildError as e: self.assertEquals(e.message, 'No arch list for tag: some_package-1.2-build') def test_BaseTaskHandler_find_arch_noarch(self): @@ -550,7 +551,7 @@ class TasksTestCase(TestCase): try: obj.find_arch('noarch', host, tag) raise Exception('The BuildError Exception was not raised') - except BuildError as e: + except koji.BuildError as e: self.assertEquals(e.message, ('host test.domain.local (i386) does not support ' 'any arches of tag some_package-1.2-build (aarch64, x86_64)')) @@ -646,7 +647,7 @@ class TasksTestCase(TestCase): try: obj.getRepo(8472) raise Exception('The BuildError Exception was not raised') - except BuildError as e: + except koji.BuildError as e: obj.session.getRepo.assert_called_once_with(8472) self.assertEquals(e.message, 'no repo (and no target) for tag rhel-7.3-build')