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 20, 2024
1 parent a417e3c commit 77679b4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
14 changes: 8 additions & 6 deletions src/retasc/product_pages_api.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

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

from functools import lru_cache
from retasc import requests_session
from retasc import constants
import os

from retasc import constants, 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 Down Expand Up @@ -128,8 +128,10 @@ def get_all_active_releases_tasks_for_product(self, product_shortname: str) -> d
f"Product - {product_shortname} is not supported yet. The products we supported currently are {constants.SUPPORTED_PRODUCTS}"
)

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
13 changes: 7 additions & 6 deletions tests/test_product_pages_api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# SPDX-License-Identifier: GPL-3.0+
from retasc.product_pages_api import ProductPagesApi
from retasc.constants import UNSUPPORTED_PHASE_ID, SUPPORTED_PRODUCTS
import requests_mock
import pytest
import requests_mock

from retasc.constants import SUPPORTED_PRODUCTS, UNSUPPORTED_PHASE_ID
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 @@ -43,7 +45,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 @@ -81,8 +84,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 77679b4

Please sign in to comment.