#4357 Fix two unit test issues
Merged 3 months ago by tkopecek. Opened 3 months ago by mikem.
mikem/koji gssapi-test-stall  into  master

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

  

      def setUp(self):

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

+         # load_config modfies pathinfo, make sure it is restored

+         mock.patch('koji.pathinfo').start()

+         mock.patch('koji.BASEDIR').start()

          self.tempdir = tempfile.mkdtemp()

          self.environ = {

              'koji.hub.ConfigFile': self.tempdir + '/hub.conf',

@@ -15,6 +15,8 @@ 

          self.session = koji.ClientSession('https://koji.example.com/kojihub',

                                            {})

          self.session._callMethod = mock.MagicMock(name='_callMethod')

+         self.session.logout = mock.MagicMock(name='logout')

+         # logout bypasses _callMethod. mock needed for __del__ to work

  

      def tearDown(self):

          mock.patch.stopall()

On some systems, the gssapi test can stall when the session is deleted by the gc (trying to make a logout call to a fake hostname).

While fixing this, I also found an intermittent failure caused a test that modifies koji.pathinfo. This could cause future tests to fail path-related assertions.

Both issues fixed by a little extra mocking.

An example of the pathinfo error

tests/test_hub/test_list_archive_files.py::TestListArchiveFiles::test_image_archive FAILED                              [ 59%]

...

>           raise AssertionError(_error_message()) from cause
E           AssertionError: expected call not found.
E           Expected: _get_tarball_list(1, '/mnt/koji/vol/archive_vol/packages/somebuild/1.2.3/1.el6/images/somearchive.zip')
E             Actual: _get_tarball_list(1, '/tmp/tmpcpulut0w/vol/archive_vol/packages/somebuild/1.2.3/1.el6/images/somearchive.zip')

Ah, the latter issue was introduced recently in #4310

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

3 months ago

Commit caeac8e fixes this pull-request

Pull-Request has been merged by tkopecek

3 months ago