Skip to content

Commit

Permalink
update errata to use filter method
Browse files Browse the repository at this point in the history
- replaced duplicated filter query with method
  ErrataConnector::get_filter
- fixup unittests to use paginated api
- add fixture symlinks for exteranl_tests api
- cleanup usage of api call to not use trailing / on the api call
  • Loading branch information
yazug committed Apr 27, 2020
1 parent e65c4cd commit 0c35a5e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
11 changes: 4 additions & 7 deletions errata_tool/erratum.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,10 @@ def externalTests(self, test_type=None):
:param test_type: str, like "rpmdiff" or "covscan"
:returns: a possibly-empty list of dicts, one per result.
"""
tmpl = '/api/v1/external_tests/?filter[active]=true'
tmpl += '&filter[errata_id]={errata_id}'
if test_type:
tmpl += '&filter[test_type]={test_type}'
url = tmpl.format(errata_id=self.errata_id, test_type=test_type)
data = self.get_paginated_data(url)
return data
response = self.get_filter('/api/v1/external_tests', 'filter',
active='true', errata_id=self.errata_id,
test_type=test_type, paginated=True)
return response['data']

def _get_build_list(self, check_signatures=False):
# Grab build list; store on a per-key basis
Expand Down
2 changes: 1 addition & 1 deletion errata_tool/tests/test_external_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TestExternalTests(object):
def test_external_tests_url(self, monkeypatch, mock_get, advisory):
monkeypatch.setattr(requests, 'get', mock_get)
advisory.externalTests(test_type='rpmdiff')
assert mock_get.response.url == 'https://errata.devel.redhat.com/api/v1/external_tests/?filter[active]=true&filter[errata_id]=33840&filter[test_type]=rpmdiff&page[number]=2' # NOQA: E501
assert mock_get.response.url == 'https://errata.devel.redhat.com/api/v1/external_tests?filter[active]=true&filter[errata_id]=33840&filter[test_type]=rpmdiff&page[number]=2' # NOQA: E501

def test_external_tests_data(self, monkeypatch, mock_get, advisory):
monkeypatch.setattr(requests, 'get', mock_get)
Expand Down
2 changes: 1 addition & 1 deletion errata_tool/tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def test_filter_sample_check_url_paginated(self, monkeypatch, mock_get,
sample_connector):
monkeypatch.setattr(requests, 'get', mock_get)
assert sample_connector.get_filter(
'/api/v1/external_tests/', 'filter', errata_id='33840',
'/api/v1/external_tests', 'filter', errata_id='33840',
test_type='rpmdiff', active='true', paginated=True)
assert 'page' in mock_get.response.url

0 comments on commit 0c35a5e

Please sign in to comment.