Skip to content

Commit

Permalink
fix: resolve quality checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Faraz Maqsood authored and Muhammad Faraz Maqsood committed Sep 16, 2024
1 parent d14d18a commit 0a467f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from . import models, settings, utils
from forum import api as forum_api
from forum.utils import ForumV2RequestError


class User(models.Model):

Expand Down Expand Up @@ -142,17 +142,13 @@ def subscribed_threads(self, query_params=None):
)

def _retrieve(self, *args, **kwargs):
url = self.url(action='get', params=self.attributes)
retrieve_params = self.default_retrieve_params.copy()
retrieve_params.update(kwargs)
if self.attributes.get('course_id'):
retrieve_params['course_id'] = str(self.course_id)
if self.attributes.get('group_id'):
retrieve_params['group_id'] = self.group_id
try:
response = forum_api.retrieve_user(self.attributes["id"], retrieve_params)
except ForumV2RequestError as e:
raise str(e)
response = forum_api.retrieve_user(self.attributes["id"], retrieve_params)
self._update_from_response(response)

def retire(self, retired_username):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,18 @@ def perform_request(method, url, data_or_params=None, raw=False,
)

# For the better logging
response_to_log_and_compare = (
response.json() if response.content else response.content
)
log.info(
"""
======> FORUM <======
method: {method}
url: {url}
params: {params}
data: {data}
response: {response}
======> END <======
""".format(
method=method,
url=url,
params=params,
data=data,
response=response_to_log_and_compare,
)
""".format(method=method, url=url, params=params, data=data, response=response.json())
)

if method == "get":
Expand All @@ -109,17 +100,12 @@ def perform_request(method, url, data_or_params=None, raw=False,
headers=headers,
timeout=config.connection_timeout,
)
forum_v1_response_to_log_and_compare = (
forum_v1_response.json()
if forum_v1_response.content
else forum_v1_response.content
)
log.info(f"requested forum proxey url: {url}")
log.info(f"requested forum v1 url: {forum_v1_url}")
if forum_v1_response_to_log_and_compare != response_to_log_and_compare:
if forum_v1_response.json() != response.json():
log.error(
f"Forum v2 difference, for endpoint {forum_v1_url} with params={params}. \
Expected: {forum_v1_response_to_log_and_compare}. Got: {response_to_log_and_compare}."
Expected: {forum_v1_response.json()}. Got: {response.json()}."
)

metric_tags.append(f'status_code:{response.status_code}')
Expand Down

0 comments on commit 0a467f2

Please sign in to comment.