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::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 24, 2020
1 parent 512847e commit 2febc07
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 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.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

0 comments on commit 2febc07

Please sign in to comment.