def test_edit_live(self, client, params):
     params['description'] = 'Red Hat Ceph Storage 4.0 Is Cool'
     client.adapter.register_uri('GET',
                                 PROD +
                                 '/product_versions/RHCEPH-4.0-RHEL-8.json',
                                 json={'id': 929})
     client.adapter.register_uri('GET',
                                 PROD +
                                 '/product_versions/RHEL-7-RHCEPH-4.0.json',
                                 json={'id': 1108})
     client.adapter.register_uri('PUT', PROD + '/api/v1/releases/1017')
     result = ensure_release(client, params, check_mode=False)
     assert result['changed'] is True
     expected = 'changing description from Red Hat Ceph Storage 4.0 ' \
                'to Red Hat Ceph Storage 4.0 Is Cool'
     assert result['stdout_lines'] == [expected]
     history = client.adapter.request_history
     expected = {
         'release': {
             'description': 'Red Hat Ceph Storage 4.0 Is Cool',
             # Note: we must always include product_version_ids (CLOUDWF-6)
             'product_version_ids': [929, 1108],
         }
     }
     assert history[-1].url == PROD + '/api/v1/releases/1017'
     assert history[-1].method == 'PUT'
     assert history[-1].json() == expected
 def test_edit_check_mode(self, client, params):
     params['description'] = 'Red Hat Ceph Storage 4.0 Is Cool'
     result = ensure_release(client, params, check_mode=True)
     assert result['changed'] is True
     expected = 'changing description from Red Hat Ceph Storage 4.0 ' \
                'to Red Hat Ceph Storage 4.0 Is Cool'
     assert result['stdout_lines'] == [expected]
 def test_create(self, client, params):
     client.adapter.register_uri('GET',
                                 PROD + '/api/v1/products/RHCEPH',
                                 json={'data': {
                                     'id': 104
                                 }})
     client.adapter.register_uri('GET',
                                 PROD +
                                 '/api/v1/user/[email protected]',
                                 json={'id': 123456})
     client.adapter.register_uri(
         'GET',
         PROD + '/api/v1/releases?filter%5Bname%5D=rhceph-4.0',
         json={'data': []})
     client.adapter.register_uri('GET',
                                 PROD +
                                 '/product_versions/RHCEPH-4.0-RHEL-8.json',
                                 json={'id': 929})
     client.adapter.register_uri('GET',
                                 PROD +
                                 '/product_versions/RHEL-7-RHCEPH-4.0.json',
                                 json={'id': 1108})
     client.adapter.register_uri('POST',
                                 PROD + '/api/v1/releases',
                                 status_code=201)
     result = ensure_release(client, params, check_mode=False)
     assert result['changed'] is True
     assert result['stdout_lines'] == ['created rhceph-4.0']
     history = client.adapter.request_history
     expected = {
         'release': {
             'name': 'rhceph-4.0',
             'description': 'Red Hat Ceph Storage 4.0',
             'brew_tags': [],
             'product_id': 104,
             'program_manager_id': 123456,
             'product_version_ids': [929, 1108],
             'isactive': True,
             'enable_batching': False,
             'ship_date': '2020-01-31',
             'type': 'QuarterlyUpdate',  # Not needed, todo: remove
             'allow_shadow': False,
             'allow_blocker': False,
             'internal_target_release': '',
             'disable_acl': False,
             'allow_pkg_dupes': True,
             'limit_bugs_by_product': False,
             'blocker_flags': 'ceph-4',
             'enabled': True,
             'allow_exception': False,
         },
         'type': 'QuarterlyUpdate',
     }
     assert history[-1].url == PROD + '/api/v1/releases'
     assert history[-1].method == 'POST'
     assert history[-1].json() == expected
 def test_edit_product_versions(self, client, params):
     params['product_versions'] = ['RHCEPH-4.0-RHEL-8']
     client.adapter.register_uri('GET',
                                 PROD +
                                 '/product_versions/RHCEPH-4.0-RHEL-8.json',
                                 json={'id': 929})
     client.adapter.register_uri('PUT', PROD + '/api/v1/releases/1017')
     result = ensure_release(client, params, check_mode=False)
     assert result['changed'] is True
     assert 'changing product_versions' in result['stdout_lines'][0]
     history = client.adapter.request_history
     expected = {'release': {'product_version_ids': [929]}}
     assert history[-1].url == PROD + '/api/v1/releases/1017'
     assert history[-1].method == 'PUT'
     assert history[-1].json() == expected
 def test_unchanged(self, client, params, check_mode):
     result = ensure_release(client, params, check_mode)
     assert result['changed'] is False