#4082 More mocking cleanup
Merged 10 months ago by tkopecek. Opened a year ago by mikem.
mikem/koji cli-test-oddity  into  master

@@ -339,7 +339,7 @@ 

          self.download_file.assert_not_called()

  

      def test_handle_download_parent_not_finished(self):

-         args = [str(self.parent_task_id)]

+         args = [str(self.parent_task_id), '--nowait']

          self.session.getTaskInfo.return_value = {

              'id': self.parent_task_id,

              'method': 'buildArch',

@@ -36,6 +36,7 @@ 

          koji.BASEDIR = self.orig_basedir

          koji.pathinfo.topdir = self.orig_pathinfo_topdir

          cli.load_plugins = self.orig_load_plugins

+         mock.patch.stopall()

  

      def test_get_options(self):

          self.read_config.return_value = self.config_dict

@@ -50,6 +50,7 @@ 

          else:

              os.environ['TZ'] = self.original_timezone

              time.tzset()

+         mock.patch.stopall()

  

      def test_hostinfo_without_option(self):

          self.session.getChannel.return_value = None

@@ -42,6 +42,7 @@ 

          else:

              os.environ['TZ'] = self.original_timezone

          time.tzset()

+         mock.patch.stopall()

  

      def test_list_external_repos_with_args(self):

          arguments = ['arg']

@@ -46,6 +46,7 @@ 

          else:

              os.environ['TZ'] = self.original_timezone

              time.tzset()

+         mock.patch.stopall()

  

      def __vm(self, result):

          m = koji.VirtualCall('mcall_method', [], {})

@@ -85,6 +85,7 @@ 

          else:

              os.environ['TZ'] = self.original_timezone

          time.tzset()

+         mock.patch.stopall()

  

      @mock.patch('sys.stdout', new_callable=six.StringIO)

      @mock.patch('koji.util.eventFromOpts', return_value={'id': 1000,

@@ -12,6 +12,9 @@ 

          self.find_build_id = mock.patch('kojihub.kojihub.find_build_id').start()

          self.lookup_name = mock.patch('kojihub.kojihub.lookup_name').start()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_non_exist_build_string_with_strict(self):

          build = 'build-1-23'

          self.find_build_id.side_effect = koji.GenericError('No such build: %s' % build)

@@ -20,6 +20,9 @@ 

          self.build_tag_id = 1

          self.dest_tag_id = 2

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_get_build_targets_strings(self):

          self.name_or_id_clause.return_value = '(build_target.name = %(build_target_name)s)', \

                                                {'build_target_name': 'build-target-url'}

@@ -14,6 +14,9 @@ 

          self.get_win_build = mock.patch('kojihub.kojihub.get_win_build').start()

          self.get_image_build = mock.patch('kojihub.kojihub.get_image_build').start()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_no_build(self):

          self.get_build.return_value = None

  

@@ -12,6 +12,9 @@ 

          self.context = mock.patch('kojihub.kojihub.context').start()

          self.exports = kojihub.RootExports()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_wrong_type_channelInfo(self):

          # dict

          channel_info = {'channel': 'val'}

@@ -12,6 +12,9 @@ 

          self.get_user = mock.patch('kojihub.kojihub.get_user').start()

          self.exports = kojihub.RootExports()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_non_exist_group(self):

          group = 'test-group'

          self.get_user.return_value = []

@@ -11,6 +11,9 @@ 

          self.maxDiff = None

          self.find_build_id = mock.patch('kojihub.kojihub.find_build_id').start()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_build_id_not_found(self):

          self.find_build_id.return_value = None

          result = kojihub.get_image_build('test-build.1-23.1')

@@ -11,6 +11,9 @@ 

          self.maxDiff = None

          self.find_build_id = mock.patch('kojihub.kojihub.find_build_id').start()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_build_id_not_found(self):

          self.find_build_id.return_value = None

          result = kojihub.get_maven_build('test-build.1-23.1')

@@ -12,6 +12,9 @@ 

          self.get_build = mock.patch('kojihub.kojihub.get_build').start()

          self.binfo = {'name': 'name', 'version': 'version'}

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_get_next_release_new(self):

          # no previous build

          self.qp_execute_one_return_value = None

@@ -14,6 +14,9 @@ 

          self.userinfo = {'id': 123, 'name': 'testuser'}

          self.exports.getLoggedInUser = mock.MagicMock()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_get_session_info_not_logged(self):

          self.context.session.logged_in = False

          result = self.exports.getSessionInfo()

@@ -19,6 +19,9 @@ 

          self.build_tag_info = {'id': 111, 'name': self.build_tag}

          self.repo_info = {'id': 123, 'name': self.repo}

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_valid(self):

          self.get_tag.return_value = self.build_tag_info

          self.get_external_repo.return_value = self.repo_info

@@ -15,6 +15,9 @@ 

          self.list_user_krb_principals = mock.patch(

              'kojihub.kojihub.list_user_krb_principals').start()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_wrong_format_user_info(self):

          userinfo = ['test-user']

          with self.assertRaises(koji.GenericError) as cm:

@@ -11,6 +11,9 @@ 

          self.maxDiff = None

          self.find_build_id = mock.patch('kojihub.kojihub.find_build_id').start()

  

+     def tearDown(self):

+         mock.patch.stopall()

+ 

      def test_build_id_not_found(self):

          self.find_build_id.return_value = None

          result = kojihub.get_win_build('test-build.1-23.1')

@@ -33,6 +33,7 @@ 

  

      def tearDown(self):

          kojihub.QueryProcessor.iterchunksize = self.original_chunksize

+         mock.patch.stopall()

  

      def test_basic_instantiation(self):

          kojihub.QueryProcessor()  # No exception!

@@ -42,6 +42,8 @@ 

          if hasattr(context, 'protonmsg_msgs'):

              del context.protonmsg_msgs

          del self.conf

+         mock.patch.stopall()

+ 

  

      def assertMsg(self, topic, body=None, **kws):

          self.assertTrue(hasattr(context, 'protonmsg_msgs'))

Followup to #4068

Fix more missing tearDown code and fix a cli test that fails when run on a console.

Metadata Update from @tkopecek:
- Pull-request tagged with: no_qe

10 months ago

Commit 2b45e98 fixes this pull-request

Pull-Request has been merged by tkopecek

10 months ago