def test_basic(self, client):
     client.adapter.register_uri('POST',
                                 PROD + '/api/v1/cdn_repos',
                                 status_code=201,
                                 json={'data': CDN_REPO})
     params = {
         'name': 'redhat-rhceph-rhceph-4-rhel8',
         'release_type': 'Primary',
         'content_type': 'Docker',
         'arch': 'multi',
         'variants': ['8Base-RHCEPH-4.0-Tools'],
         'package_names': ['rhceph-container'],
     }
     create_cdn_repo(client, params)
     history = client.adapter.request_history
     assert len(history) == 1
     expected = {
         'cdn_repo': {
             'name': 'redhat-rhceph-rhceph-4-rhel8',
             'release_type': 'Primary',
             'content_type': 'Docker',
             'arch_name': 'multi',
             'variant_names': ['8Base-RHCEPH-4.0-Tools'],
             'package_names': ['rhceph-container'],
         }
     }
     assert history[0].json() == expected
 def test_failure(self, client):
     client.adapter.register_uri('POST',
                                 PROD + '/api/v1/cdn_repos',
                                 status_code=400,
                                 json={
                                     'status': 400,
                                     'error': 'Bad Request'
                                 })
     with pytest.raises(ValueError) as err:
         create_cdn_repo(client, {})
     assert str(err.value) == 'Bad Request'
 def test_failure_error_not_set(self, client):
     client.adapter.register_uri('POST',
                                 PROD + '/api/v1/cdn_repos',
                                 status_code=400,
                                 json={
                                     'status': 400,
                                     'best_actor': 'Tom Hanks'
                                 })
     with pytest.raises(ValueError) as err:
         create_cdn_repo(client, {})
     assert 'Tom Hanks' in str(err.value)