#2922 listBuilds returns empty list, not error when not existing
Merged 11 months ago by tkopecek. Opened 11 months ago by jcupova.
jcupova/koji issue-1209-2  into  master

file modified
+7 -2
@@ -11406,10 +11406,15 @@ 

                   'LEFT JOIN users ON build.owner = users.id']

          clauses = []

          if packageID is not None:

-             packageID = get_package_id(packageID, strict=True)

+             packageID = get_package_id(packageID)

+             if not packageID:

+                 return []

              clauses.append('package.id = %(packageID)i')

          if userID is not None:

-             userID = get_user(userID, strict=True)['id']

+             userinfo = get_user(userID)

+             if not userinfo:

+                 return []

+             userID = userinfo['id']

              clauses.append('users.id = %(userID)i')

          if volumeID is not None:

              clauses.append('volume.id = %(volumeID)i')

@@ -2,7 +2,6 @@ 

  

  import mock

  

- import koji

  import kojihub

  

  QP = kojihub.QueryProcessor
@@ -44,10 +43,9 @@ 

  

      def test_wrong_package(self):

          package = 'test-package'

-         kojihub.get_package_id.return_value = package

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

-             self.exports.listBuilds(packageID=package)

-         self.assertEqual('No such entry in table package: %s' % package, str(cm.exception))

+         kojihub.get_package_id.return_value = None

+         rv = self.exports.listBuilds(packageID=package)

+         self.assertEquals(rv, [])

  

      @mock.patch('kojihub.get_package_id')

      def test_package_string(self, get_package_id):
@@ -80,7 +78,6 @@ 

      @mock.patch('kojihub.get_user')

      def test_wrong_user(self, get_user):

          user = 'test-user'

-         get_user.side_effect = koji.GenericError('No such user: %s' % user)

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

-             self.exports.listBuilds(userID=user)

-         self.assertEqual('No such user: %s' % user, str(cm.exception))

+         get_user.return_value = None

+         rv = self.exports.listBuilds(userID=user)

+         self.assertEquals(rv, [])

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

11 months ago

rebased onto b383152

11 months ago

Metadata Update from @jobrauer:
- Pull-request tagged with: testing-done

11 months ago

Commit fada0c9 fixes this pull-request

Pull-Request has been merged by tkopecek

11 months ago