Skip to content

Commit

Permalink
chore: pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzawaleed01 committed Sep 9, 2024
2 parents ca61002 + 5afa00b commit d249767
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 97 deletions.
7 changes: 4 additions & 3 deletions license_manager/apps/api/v1/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,8 @@ def test_bulk_revoke_no_valid_subscription_plan_superuser(self, mock_revoke_lice
response = self.api_client.post(request_url, request_payload)

assert response.status_code == status.HTTP_404_NOT_FOUND
expected_response_message = {'error_messages': [{'error': 'No SubscriptionPlan identified by {} exists'.format(non_existent_uuid)}]}
expected_response_message = {'error_messages': [
{'error': 'No SubscriptionPlan identified by {} exists'.format(non_existent_uuid)}]}
self.assertEqual(expected_response_message, response.json())
self.assertFalse(mock_revoke_license.called)

Expand Down Expand Up @@ -3178,10 +3179,10 @@ def test_bulk_revoke_license_not_found(self, mock_revoke_license, mock_execute_p
response_data = response.json()
self.assertIn('revocation_results', response_data)
self.assertIn('error_messages', response_data)

self.assertEqual(len(response_data['revocation_results']), 1)
self.assertIsInstance(response_data['revocation_results'][0]['user_email'], str)

self.assertEqual(len(response_data['error_messages']), 1)
self.assertIsInstance(response_data['error_messages'][0]['user_email'], str)
self.assertEqual(response_data['error_messages'][0]['error'], expected_error_msg)
Expand Down
15 changes: 10 additions & 5 deletions license_manager/apps/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,11 @@ def _validate_data(self, data):
"""
serializer_class = self.get_serializer_class()
serializer = serializer_class(data=data)
serializer.is_valid(raise_exception=True)
try:
serializer.is_valid(raise_exception=True)
except ValidationError:
logger.error("Received invalid input: %s", data)
raise

def _trim_already_associated_emails(self, subscription_plan, user_emails):
"""
Expand Down Expand Up @@ -1313,7 +1317,8 @@ def bulk_revoke(self, request, subscription_uuid=None):
Response:
200 OK - All revocations were successful. Returns a list of successful revocations.
207 Multi-Status - Some revocations were successful, but others failed. Returns both successful and failed revocations.
207 Multi-Status - Some revocations were successful, but others failed.
Returns both successful and failed revocations.
400 Bad Request - An error occurred when processing the request (e.g., invalid data format).
404 Not Found - The subscription plan was not found.
Expand All @@ -1335,11 +1340,11 @@ def bulk_revoke(self, request, subscription_uuid=None):
]
}
The revocation process attempts to revoke all requested licenses. If any revocations fail,
the successful revocations are still committed, and details of both successful and failed
The revocation process attempts to revoke all requested licenses. If any revocations fail,
the successful revocations are still committed, and details of both successful and failed
revocations are returned in the response.
If the number of requested revocations exceeds the remaining revocations for the plan,
If the number of requested revocations exceeds the remaining revocations for the plan,
a 400 Bad Request response is returned without processing any revocations.
"""
# to capture custom metrics
Expand Down
2 changes: 1 addition & 1 deletion license_manager/apps/subscriptions/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _renew_all_licenses(original_licenses, future_plan, is_auto_renewed):
original_license.renewed_to = future_license
License.bulk_update(
future_licenses,
['status', 'user_email', 'lms_user_id', 'activation_date', 'assigned_date'],
['status', 'user_email', 'lms_user_id', 'activation_key', 'activation_date', 'assigned_date'],
)
License.bulk_update(
original_licenses,
Expand Down
2 changes: 2 additions & 0 deletions license_manager/apps/subscriptions/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def _assert_all_licenses_renewed(self, future_plan):
self.assertEqual(future_license.status, original_license.status)
self.assertEqual(future_license.user_email, original_license.user_email)
self.assertEqual(future_license.lms_user_id, original_license.lms_user_id)
self.assertEqual(future_license.activation_key, original_license.activation_key)
if original_license.status == constants.ACTIVATED:
self.assertEqual(future_license.activation_date, expected_activation_datetime)
self.assertEqual(future_license.assigned_date, NOW)
Expand All @@ -108,6 +109,7 @@ def test_renewal_processed_with_no_existing_future_plan(self):
LicenseFactory.create(
subscription_plan=prior_plan,
status=constants.ASSIGNED,
activation_key=uuid.uuid4(),
user_email='assigned_user_{}@example.com'.format(i)
) for i in range(5)
]
Expand Down
18 changes: 8 additions & 10 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ backoff==1.10.0
# analytics-python
billiard==4.2.0
# via celery
boto3==1.34.158
boto3==1.35.5
# via django-ses
botocore==1.34.158
botocore==1.35.5
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -117,7 +117,7 @@ django-model-utils==4.5.1
# -r requirements/base.in
# edx-celeryutils
# edx-rbac
django-ses==4.1.0
django-ses==4.1.1
# via -r requirements/base.in
django-simple-history==3.7.0
# via -r requirements/base.in
Expand Down Expand Up @@ -165,13 +165,13 @@ edx-drf-extensions==10.3.0
# edx-rbac
edx-opaque-keys==2.10.0
# via edx-drf-extensions
edx-rbac==1.9.0
edx-rbac==1.10.0
# via -r requirements/base.in
edx-rest-api-client==5.7.1
# via -r requirements/base.in
edx-toggles==5.2.0
# via -r requirements/base.in
idna==3.7
idna==3.8
# via requests
inflection==0.5.1
# via drf-spectacular
Expand Down Expand Up @@ -232,9 +232,7 @@ python-slugify==8.0.4
python3-openid==3.2.0
# via social-auth-core
pytz==2024.1
# via
# -r requirements/base.in
# django-ses
# via -r requirements/base.in
pyyaml==6.0.2
# via
# code-annotations
Expand Down Expand Up @@ -265,7 +263,7 @@ s3transfer==0.10.2
# via boto3
semantic-version==2.10.0
# via edx-drf-extensions
simplejson==3.19.2
simplejson==3.19.3
# via -r requirements/base.in
six==1.16.0
# via
Expand All @@ -283,7 +281,7 @@ social-auth-core==4.5.4
# social-auth-app-django
sqlparse==0.5.1
# via django
stevedore==5.2.0
stevedore==5.3.0
# via
# code-annotations
# edx-django-utils
Expand Down
26 changes: 12 additions & 14 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ billiard==4.2.0
# via
# -r requirements/validation.txt
# celery
boto3==1.34.158
boto3==1.35.5
# via
# -r requirements/validation.txt
# django-ses
botocore==1.34.158
botocore==1.35.5
# via
# -r requirements/validation.txt
# boto3
Expand Down Expand Up @@ -185,7 +185,7 @@ django-model-utils==4.5.1
# -r requirements/validation.txt
# edx-celeryutils
# edx-rbac
django-ses==4.1.0
django-ses==4.1.1
# via -r requirements/validation.txt
django-simple-history==3.7.0
# via -r requirements/validation.txt
Expand Down Expand Up @@ -237,29 +237,29 @@ edx-drf-extensions==10.3.0
# edx-rbac
edx-i18n-tools==1.6.2
# via -r requirements/validation.txt
edx-lint==5.3.7
edx-lint==5.4.0
# via -r requirements/validation.txt
edx-opaque-keys==2.10.0
# via
# -r requirements/validation.txt
# edx-drf-extensions
edx-rbac==1.9.0
edx-rbac==1.10.0
# via -r requirements/validation.txt
edx-rest-api-client==5.7.1
# via -r requirements/validation.txt
edx-toggles==5.2.0
# via -r requirements/validation.txt
factory-boy==3.3.0
factory-boy==3.3.1
# via -r requirements/validation.txt
faker==26.3.0
faker==28.0.0
# via
# -r requirements/validation.txt
# factory-boy
freezegun==1.5.1
# via -r requirements/validation.txt
gunicorn==23.0.0
# via -r requirements/dev.in
idna==3.7
idna==3.8
# via
# -r requirements/validation.txt
# requests
Expand Down Expand Up @@ -459,9 +459,7 @@ python3-openid==3.2.0
# -r requirements/validation.txt
# social-auth-core
pytz==2024.1
# via
# -r requirements/validation.txt
# django-ses
# via -r requirements/validation.txt
pywatchman==2.0.0
# via -r requirements/dev.in
pyyaml==6.0.2
Expand Down Expand Up @@ -505,7 +503,7 @@ semantic-version==2.10.0
# via
# -r requirements/validation.txt
# edx-drf-extensions
simplejson==3.19.2
simplejson==3.19.3
# via -r requirements/validation.txt
six==1.16.0
# via
Expand Down Expand Up @@ -538,7 +536,7 @@ sqlparse==0.5.1
# -r requirements/validation.txt
# django
# django-debug-toolbar
stevedore==5.2.0
stevedore==5.3.0
# via
# -r requirements/validation.txt
# code-annotations
Expand All @@ -548,7 +546,7 @@ text-unidecode==1.3
# via
# -r requirements/validation.txt
# python-slugify
tomlkit==0.13.0
tomlkit==0.13.2
# via
# -r requirements/validation.txt
# pylint
Expand Down
28 changes: 13 additions & 15 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ billiard==4.2.0
# via
# -r requirements/test.txt
# celery
boto3==1.34.158
boto3==1.35.5
# via
# -r requirements/test.txt
# django-ses
botocore==1.34.158
botocore==1.35.5
# via
# -r requirements/test.txt
# boto3
Expand Down Expand Up @@ -177,7 +177,7 @@ django-model-utils==4.5.1
# -r requirements/test.txt
# edx-celeryutils
# edx-rbac
django-ses==4.1.0
django-ses==4.1.1
# via -r requirements/test.txt
django-simple-history==3.7.0
# via -r requirements/test.txt
Expand Down Expand Up @@ -236,27 +236,27 @@ edx-drf-extensions==10.3.0
# via
# -r requirements/test.txt
# edx-rbac
edx-lint==5.3.7
edx-lint==5.4.0
# via -r requirements/test.txt
edx-opaque-keys==2.10.0
# via
# -r requirements/test.txt
# edx-drf-extensions
edx-rbac==1.9.0
edx-rbac==1.10.0
# via -r requirements/test.txt
edx-rest-api-client==5.7.1
# via -r requirements/test.txt
edx-toggles==5.2.0
# via -r requirements/test.txt
factory-boy==3.3.0
factory-boy==3.3.1
# via -r requirements/test.txt
faker==26.3.0
faker==28.0.0
# via
# -r requirements/test.txt
# factory-boy
freezegun==1.5.1
# via -r requirements/test.txt
idna==3.7
idna==3.8
# via
# -r requirements/test.txt
# requests
Expand Down Expand Up @@ -430,9 +430,7 @@ python3-openid==3.2.0
# -r requirements/test.txt
# social-auth-core
pytz==2024.1
# via
# -r requirements/test.txt
# django-ses
# via -r requirements/test.txt
pyyaml==6.0.2
# via
# -r requirements/test.txt
Expand Down Expand Up @@ -478,7 +476,7 @@ semantic-version==2.10.0
# via
# -r requirements/test.txt
# edx-drf-extensions
simplejson==3.19.2
simplejson==3.19.3
# via -r requirements/test.txt
six==1.16.0
# via
Expand All @@ -503,7 +501,7 @@ social-auth-core==4.5.4
# -r requirements/test.txt
# edx-auth-backends
# social-auth-app-django
soupsieve==2.5
soupsieve==2.6
# via beautifulsoup4
sphinx==8.0.2
# via
Expand All @@ -528,7 +526,7 @@ sqlparse==0.5.1
# via
# -r requirements/test.txt
# django
stevedore==5.2.0
stevedore==5.3.0
# via
# -r requirements/test.txt
# code-annotations
Expand All @@ -539,7 +537,7 @@ text-unidecode==1.3
# via
# -r requirements/test.txt
# python-slugify
tomlkit==0.13.0
tomlkit==0.13.2
# via
# -r requirements/test.txt
# pylint
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ wheel==0.44.0
# The following packages are considered to be unsafe in a requirements file:
pip==24.2
# via -r requirements/pip.in
setuptools==72.1.0
setuptools==73.0.1
# via -r requirements/pip.in
Loading

0 comments on commit d249767

Please sign in to comment.