示例#1
0
 def test_create_data(self, monkeypatch, mock_get, mock_post):
     monkeypatch.setattr(requests, 'get', mock_get)
     monkeypatch.setattr(requests, 'post', mock_post)
     monkeypatch.setattr(ErrataConnector, '_username', 'test')
     Release.create(**self.create_kwargs)
     today = date.today()
     ship_date = today.strftime("%Y-%b-%d")
     expected = {
         'type': 'QuarterlyUpdate',
         'release[allow_blocker]': 0,
         'release[allow_exception]': 0,
         'release[allow_pkg_dupes]': 1,
         'release[allow_shadow]': 0,
         'release[blocker_flags]': 'ceph-3.0',
         'release[description]': 'Red Hat Ceph Storage 3.0',
         'release[default_brew_tag]': 'ceph-3.0-rhel-7-candidate',
         'release[enable_batching]': 0,
         'release[enabled]': 1,
         'release[is_deferred]': 0,
         'release[is_pdc]': 0,
         'release[name]': 'rhceph-3.0',
         'release[product_id]': 104,
         'release[program_manager_id]': 3003046,
         'release[product_version_ids][]': set([665]),
         'release[ship_date]': ship_date,
         'release[type]': 'QuarterlyUpdate',
     }
     assert mock_post.kwargs['data'] == expected
示例#2
0
def create(args):
    try:
        r = Release(name=args.name)
        print('%s is already defined at %s' % (r.name, r.url))
        sys.exit(1)
    except NoReleaseFoundError:
        pass
    if args.dry_run:
        print('DRY RUN: would create new release:')
        print('Name: %s' % args.name)
        print('Product: %s' % args.product)
        print('Product Versions: %s' % args.product_version)
        print('Type: %s' % args.type)
        print('Program manager: %s' % args.program_manager)
        print('Blocker flags: %s' % args.blocker_flags)
        print('Default Brew tag: %s' % args.default_brew_tag)
        return
    r = Release.create(
        name=args.name,
        product=args.product,
        product_versions=args.product_version,
        type=args.type,
        program_manager=args.program_manager,
        blocker_flags=args.blocker_flags,
        default_brew_tag=args.default_brew_tag,
    )
    print('created new %s release' % args.name)
    print('visit %s to edit further' % r.edit_url)
示例#3
0
def list_advisories(args):
    try:
        r = Release(name=args.name)
    except NoReleaseFoundError:
        print('%s release not found' % args.name)
        sys.exit(1)
    advisories = r.advisories()
    if args.status == 'OPEN':  # an alias meaning "all open statuses"
        interested_status = ['NEW_FILES', 'QE', 'REL_PREP', 'IN_PUSH']
    else:
        interested_status = [args.status]

    if args.status:
        advisories = [
            a for a in advisories if a['status'] in interested_status
        ]
        if not advisories:
            print('no %s advisories found for release %s' %
                  (args.status, args.name))
    else:
        if not advisories:
            print('no advisories found for release %s' % args.name)
    for advisory in advisories:
        # hack, avoid initializing the full Erratum class just to get the URL:
        url = posixpath.join(ErrataConnector._url, 'errata',
                             str(advisory['id']))
        print('------------------------------')
        print('URL: %s' % url)
        print('synopsis: %s' % advisory['synopsis'])
        print('status: %s' % advisory['status'])
示例#4
0
 def test_create_url(self, monkeypatch, mock_get, mock_post):
     monkeypatch.setattr(requests, 'get', mock_get)
     monkeypatch.setattr(requests, 'post', mock_post)
     monkeypatch.setattr(ErrataConnector, '_username', 'test')
     Release.create(**self.create_kwargs)
     expected = 'https://errata.devel.redhat.com/release/create'
     assert mock_post.response.url == expected
示例#5
0
 def test_create_data(self, monkeypatch, mock_get, mock_post):
     monkeypatch.setattr(requests, 'get', mock_get)
     monkeypatch.setattr(requests, 'post', mock_post)
     monkeypatch.setattr(ErrataConnector, '_username', 'test')
     Release.create(**self.create_kwargs)
     today = date.today()
     ship_date = today.strftime("%Y-%b-%d")
     expected = {
         'type': 'QuarterlyUpdate',
         'release[allow_blocker]': 0,
         'release[allow_exception]': 0,
         'release[allow_pkg_dupes]': 1,
         'release[allow_shadow]': 0,
         'release[blocker_flags]': 'ceph-3.y',
         'release[description]': 'Red Hat Ceph Storage 3.1',
         'release[default_brew_tag]': 'ceph-3.1-rhel-7-candidate',
         'release[enable_batching]': 0,
         'release[enabled]': 1,
         'release[is_deferred]': 0,
         'release[is_pdc]': 0,
         'release[name]': 'rhceph-3.1',
         'release[product_id]': 104,
         'release[program_manager_id]': 3003046,
         'release[product_version_ids][]': set([783]),
         'release[ship_date]': ship_date,
         'release[type]': 'QuarterlyUpdate',
     }
     assert mock_post.kwargs['data'] == expected
示例#6
0
 def test_create_url(self, monkeypatch, mock_get, mock_post):
     monkeypatch.setattr(requests, 'get', mock_get)
     monkeypatch.setattr(requests, 'post', mock_post)
     monkeypatch.setattr(ErrataConnector, '_username', 'test')
     Release.create(**self.create_kwargs)
     expected = 'https://errata.devel.redhat.com/release/create'
     assert mock_post.response.url == expected
示例#7
0
 def test_plus(self, monkeypatch, mock_get):
     monkeypatch.setattr(requests, 'get', mock_get)
     release = Release(name='RHEL-8.4.0.Z.MAIN+EUS')
     assert release.name == 'RHEL-8.4.0.Z.MAIN+EUS'
     assert mock_get.response.url == self.expected_url
     assert mock_get.kwargs['params']['filter[name]'] == \
         'RHEL-8.4.0.Z.MAIN+EUS'
示例#8
0
def get(args):
    try:
        r = Release(name=args.name)
        print('Name: %s' % r.name)
        print('Description: %s' % r.description)
        print('URL: %s' % r.url)
    except NoReleaseFoundError:
        print('%s release not found' % args.name)
        sys.exit(1)
示例#9
0
 def test_plus_encoded(self, monkeypatch, mock_get, recwarn):
     monkeypatch.setattr(requests, 'get', mock_get)
     release = Release(name='RHEL-8.4.0.Z.MAIN%2BEUS')
     assert release.name == 'RHEL-8.4.0.Z.MAIN+EUS'
     assert mock_get.response.url == self.expected_url
     assert mock_get.kwargs['params']['filter[name]'] == \
         'RHEL-8.4.0.Z.MAIN+EUS'
     assert len(recwarn.list) == 1
     assert recwarn.pop(DeprecationWarning)
示例#10
0
def list_advisories(args):
    try:
        r = Release(name=args.name)
    except NoReleaseFoundError:
        print('%s release not found' % args.name)
        sys.exit(1)
    advisories = r.advisories()
    if args.status:
        advisories = [a for a in advisories if a['status'] == args.status]
        if not advisories:
            print('no %s advisories found for release %s' % (args.status,
                                                             args.name))
    else:
        if not advisories:
            print('no advisories found for release %s' % args.name)
    for advisory in advisories:
        # hack, avoid initializing the full Erratum class just to get the URL:
        url = posixpath.join(ErrataConnector._url, 'errata',
                             str(advisory['id']))
        print('------------------------------')
        print('URL: %s' % url)
        print('synopsis: %s' % advisory['synopsis'])
        print('status: %s' % advisory['status'])
示例#11
0
def release(monkeypatch, mock_get):
    monkeypatch.delattr('requests.sessions.Session.request')
    monkeypatch.setattr(ErrataConnector, '_auth', None)
    monkeypatch.setattr(requests, 'get', mock_get)
    return Release(name='rhceph-3.0')