Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 21, 2024
1 parent 650a23d commit 6e4de17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/retasc/product_pages_api.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@

# SPDX-License-Identifier: GPL-3.0-or-later
"""
Production Pages API
"""

from functools import lru_cache

from retasc import requests_session


class ProductPagesApi:
"""
Product Pages API Client
"""

def __init__(self, api_url: str):
self.api_url = api_url
self.session = requests_session.requests_session()
Expand All @@ -28,7 +30,6 @@ def releases_by_product_phase(
The response have the following fields:shortname,product_shortname,ga_date,phase_display
phase id 1000 is unsupported, `lt` is less than
"""
Unsupported_phase_id = 1000
pp_release_url = self.api_url + "releases/"
opt = {
"product__shortname": product_shortname,
Expand Down Expand Up @@ -121,8 +122,10 @@ def get_all_active_releases_tasks_for_product(self, product_shortname: str) -> d
https://{pp_release_url}{release_short_name}/schedule-tasks/fields=name,slug,date_start,date_finish
"""

releases_list = ProductPagesApi.releases_by_product_phase(self, product_shortname)
all_tasks = {} # type: dict
releases_list = ProductPagesApi.releases_by_product_phase(
self, product_shortname
)
all_tasks = {} # type: dict
all_tasks[product_shortname] = {}
for r in releases_list:
r_name = r["shortname"]
Expand Down
9 changes: 5 additions & 4 deletions tests/test_product_pages_api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SPDX-License-Identifier: GPL-3.0+
from retasc.product_pages_api import ProductPagesApi
import requests_mock

from retasc.product_pages_api import ProductPagesApi

PP_URL = "https://product_pages.example.com/"
PP_API = ProductPagesApi(PP_URL)


def test_get_pp_url_from_env():
assert PP_API.api_url == PP_URL

Expand Down Expand Up @@ -41,7 +43,8 @@ def test_releases_by_product_phase():
# make sure when fields = shortname only, only shortname should appear in get url's fields
with requests_mock.Mocker() as m:
m.get(
f"{PP_URL}releases/?product__shortname={test_prod}&fields=shortname", json=res
f"{PP_URL}releases/?product__shortname={test_prod}&fields=shortname",
json=res,
)
resp = PP_API.releases_by_product_phase(test_prod, False, "shortname")

Expand Down Expand Up @@ -79,8 +82,6 @@ def test_release_schedules_by_flags():
res = [
{
"date_finish": "2021-04-08",
"date_start": "2021-03-25",
"name": "Initial configuration for RHSCL 3.8",
"date_start": "2021-09-27",
"name": "File ticket for GA - RC Compose",
"release_shortname": "rhscl-3-8",
Expand Down
6 changes: 4 additions & 2 deletions tests/test_requests_session.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SPDX-License-Identifier: GPL-3.0+
import json
from retasc import requests_session

import requests_mock

from retasc import requests_session


class TestRequestSession(object):
class TestRequestSession:
def test_req_get(self):
client = requests_session.requests_session()
with requests_mock.Mocker() as m:
Expand Down

0 comments on commit 6e4de17

Please sign in to comment.