#1948 check package list existence before blocking
Merged 4 years ago by tkopecek. Opened 4 years ago by tkopecek.
tkopecek/koji issue1177  into  master

file modified
+6
@@ -1043,6 +1043,12 @@ 

  

  def pkglist_block(taginfo, pkginfo, force=False):

      """Block the package in tag"""

+     # check pkg list existence

+     tag = get_tag(taginfo, strict=True)

+     pkg = lookup_package(pkginfo, strict=True)

+     if not readPackageList(tag['id'], pkgID=pkg['id'], inherit=True):

+         raise koji.GenericError("Package %s is not in tag listing for %s" % \

+                                 (pkg['name'], tag['name']))

      pkglist_add(taginfo, pkginfo, block=True, force=force)

  

  def pkglist_unblock(taginfo, pkginfo, force=False):

@@ -19,11 +19,20 @@ 

      def tearDown(self):

          mock.patch.stopall()

  

+     @mock.patch('kojihub.readPackageList')

+     @mock.patch('kojihub.lookup_package')

+     @mock.patch('kojihub.get_tag')

      @mock.patch('kojihub.pkglist_add')

-     def test_pkglist_block(self, pkglist_add):

+     def test_pkglist_block(self, pkglist_add, get_tag, lookup_package, readPackageList):

          force = mock.MagicMock()

+         get_tag.return_value = {'name': 'tag', 'id': 123}

+         lookup_package.return_value = {'name': 'pkg', 'id': 321}

+         readPackageList.return_value = ['pkg']

+ 

          kojihub.pkglist_block('tag', 'pkg', force=force)

  

+         get_tag.assert_called_once_with('tag', strict=True)

+         lookup_package.assert_called_once_with('pkg', strict=True)

          pkglist_add.assert_called_once_with('tag', 'pkg', block=True, force=force)

  

      @mock.patch('kojihub._pkglist_remove')

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

4 years ago

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

4 years ago

Commit e015942 fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago