mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
Bump flake8-bugbear from 24.12.12 to 25.10.21 (#2052)
* Bump flake8-bugbear from 24.12.12 to 25.10.21 Bumps [flake8-bugbear](https://github.com/PyCQA/flake8-bugbear) from 24.12.12 to 25.10.21. - [Release notes](https://github.com/PyCQA/flake8-bugbear/releases) - [Commits](https://github.com/PyCQA/flake8-bugbear/compare/24.12.12...25.10.21) --- updated-dependencies: - dependency-name: flake8-bugbear dependency-version: 25.10.21 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Fix flake8-bugbear B042 violations in exception classes * Trigger CI re-run * Regenerate poetry.lock with Poetry 2.1.3 for CI compatibility * Regenerated poetry hash again --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alex Janousek <alex.janousek@gsa.gov>
This commit is contained in:
co-authored by
Alex Janousek
parent
61ce3b0b5c
commit
9ba2e8b1bf
@@ -29,6 +29,7 @@ GENERAL_TOKEN_ERROR_MESSAGE = TOKEN_MESSAGE_ONE + TOKEN_MESSAGE_TWO
|
|||||||
|
|
||||||
class AuthError(Exception):
|
class AuthError(Exception):
|
||||||
def __init__(self, message, code, service_id=None, api_key_id=None):
|
def __init__(self, message, code, service_id=None, api_key_id=None):
|
||||||
|
super().__init__(message, code, service_id, api_key_id)
|
||||||
self.message = {"token": [message]}
|
self.message = {"token": [message]}
|
||||||
self.short_message = message
|
self.short_message = message
|
||||||
self.code = code
|
self.code = code
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from flask import current_app
|
|||||||
|
|
||||||
class DocumentDownloadError(Exception):
|
class DocumentDownloadError(Exception):
|
||||||
def __init__(self, message, status_code):
|
def __init__(self, message, status_code):
|
||||||
|
super().__init__(message, status_code)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.status_code = status_code
|
self.status_code = status_code
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class SmsClientResponseException(ClientException):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
|
super().__init__(message)
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -699,7 +699,9 @@ def query_organization_sms_usage_for_year(organization_id, year):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def fetch_usage_year_for_organization(organization_id, year, include_all_services=False):
|
def fetch_usage_year_for_organization(
|
||||||
|
organization_id, year, include_all_services=False
|
||||||
|
):
|
||||||
year_start, year_end = get_calendar_year_dates(year)
|
year_start, year_end = get_calendar_year_dates(year)
|
||||||
today = utc_now().date()
|
today = utc_now().date()
|
||||||
|
|
||||||
|
|||||||
@@ -351,10 +351,7 @@ def dao_get_notification_counts_for_organization(service_ids, current_year):
|
|||||||
end_date = datetime(current_year + 1, 6, 16)
|
end_date = datetime(current_year + 1, 6, 16)
|
||||||
|
|
||||||
stmt1 = (
|
stmt1 = (
|
||||||
select(
|
select(Notification.service_id, func.count().label("count"))
|
||||||
Notification.service_id,
|
|
||||||
func.count().label("count")
|
|
||||||
)
|
|
||||||
.where(
|
.where(
|
||||||
Notification.service_id.in_(service_ids),
|
Notification.service_id.in_(service_ids),
|
||||||
Notification.status
|
Notification.status
|
||||||
@@ -370,10 +367,7 @@ def dao_get_notification_counts_for_organization(service_ids, current_year):
|
|||||||
)
|
)
|
||||||
|
|
||||||
stmt2 = (
|
stmt2 = (
|
||||||
select(
|
select(NotificationHistory.service_id, func.count().label("count"))
|
||||||
NotificationHistory.service_id,
|
|
||||||
func.count().label("count")
|
|
||||||
)
|
|
||||||
.where(
|
.where(
|
||||||
NotificationHistory.service_id.in_(service_ids),
|
NotificationHistory.service_id.in_(service_ids),
|
||||||
NotificationHistory.status
|
NotificationHistory.status
|
||||||
|
|||||||
+15
-6
@@ -15,7 +15,7 @@ class InvalidRequest(Exception):
|
|||||||
fields = []
|
fields = []
|
||||||
|
|
||||||
def __init__(self, message, status_code):
|
def __init__(self, message, status_code):
|
||||||
super().__init__()
|
super().__init__(message, status_code)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.status_code = status_code
|
self.status_code = status_code
|
||||||
|
|
||||||
@@ -115,16 +115,20 @@ class TooManyRequestsError(InvalidRequest):
|
|||||||
status_code = 429
|
status_code = 429
|
||||||
message_template = "Exceeded send limits ({}) for today"
|
message_template = "Exceeded send limits ({}) for today"
|
||||||
|
|
||||||
def __init__(self, sending_limit):
|
def __init__(self, sending_limit): # noqa: B042
|
||||||
self.message = self.message_template.format(sending_limit)
|
self.message = self.message_template.format(sending_limit)
|
||||||
|
self.sending_limit = sending_limit
|
||||||
|
super().__init__(self.message, self.status_code)
|
||||||
|
|
||||||
|
|
||||||
class TotalRequestsError(InvalidRequest):
|
class TotalRequestsError(InvalidRequest):
|
||||||
status_code = 429
|
status_code = 429
|
||||||
message_template = "Exceeded total application limits ({}) for today"
|
message_template = "Exceeded total application limits ({}) for today"
|
||||||
|
|
||||||
def __init__(self, sending_limit):
|
def __init__(self, sending_limit): # noqa: B042
|
||||||
self.message = self.message_template.format(sending_limit)
|
self.message = self.message_template.format(sending_limit)
|
||||||
|
self.sending_limit = sending_limit
|
||||||
|
super().__init__(self.message, self.status_code)
|
||||||
|
|
||||||
|
|
||||||
class RateLimitError(InvalidRequest):
|
class RateLimitError(InvalidRequest):
|
||||||
@@ -133,7 +137,7 @@ class RateLimitError(InvalidRequest):
|
|||||||
"Exceeded rate limit for key type {} of {} requests per {} seconds"
|
"Exceeded rate limit for key type {} of {} requests per {} seconds"
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, sending_limit, interval, key_type):
|
def __init__(self, sending_limit, interval, key_type): # noqa: B042
|
||||||
# normal keys are spoken of as "live" in the documentation
|
# normal keys are spoken of as "live" in the documentation
|
||||||
# so using this in the error messaging
|
# so using this in the error messaging
|
||||||
if key_type == KeyType.NORMAL:
|
if key_type == KeyType.NORMAL:
|
||||||
@@ -142,12 +146,17 @@ class RateLimitError(InvalidRequest):
|
|||||||
self.message = self.message_template.format(
|
self.message = self.message_template.format(
|
||||||
key_type.upper(), sending_limit, interval
|
key_type.upper(), sending_limit, interval
|
||||||
)
|
)
|
||||||
|
self.sending_limit = sending_limit
|
||||||
|
self.interval = interval
|
||||||
|
self.key_type = key_type
|
||||||
|
super().__init__(self.message, self.status_code)
|
||||||
|
|
||||||
|
|
||||||
class BadRequestError(InvalidRequest):
|
class BadRequestError(InvalidRequest):
|
||||||
message = "An error occurred"
|
message = "An error occurred"
|
||||||
|
|
||||||
def __init__(self, fields=None, message=None, status_code=400):
|
def __init__(self, fields=None, message=None, status_code=400): # noqa: B042
|
||||||
self.status_code = status_code
|
|
||||||
self.fields = fields or []
|
self.fields = fields or []
|
||||||
self.message = message if message else self.message
|
self.message = message if message else self.message
|
||||||
|
self.status_code = status_code
|
||||||
|
super().__init__(self.message, self.status_code)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class DVLAException(Exception):
|
class DVLAException(Exception):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
|
super().__init__(message)
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,9 @@ def get_organization_services_usage(organization_id):
|
|||||||
return jsonify(result="error", message="No valid year provided"), 400
|
return jsonify(result="error", message="No valid year provided"), 400
|
||||||
include_all = request.args.get("include_all_services", "false").lower() == "true"
|
include_all = request.args.get("include_all_services", "false").lower() == "true"
|
||||||
|
|
||||||
services = fetch_usage_year_for_organization(organization_id, year, include_all_services=include_all)
|
services = fetch_usage_year_for_organization(
|
||||||
|
organization_id, year, include_all_services=include_all
|
||||||
|
)
|
||||||
list_services = services.values()
|
list_services = services.values()
|
||||||
sorted_services = sorted(
|
sorted_services = sorted(
|
||||||
list_services, key=lambda s: (-s["active"], s["service_name"].lower())
|
list_services, key=lambda s: (-s["active"], s["service_name"].lower())
|
||||||
@@ -266,7 +268,9 @@ def send_notifications_on_mou_signed(organization_id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@organization_blueprint.route("/<uuid:organization_id>/message-allowance", methods=["GET"])
|
@organization_blueprint.route(
|
||||||
|
"/<uuid:organization_id>/message-allowance", methods=["GET"]
|
||||||
|
)
|
||||||
def get_organization_message_allowance(organization_id):
|
def get_organization_message_allowance(organization_id):
|
||||||
|
|
||||||
check_suspicious_id(organization_id)
|
check_suspicious_id(organization_id)
|
||||||
@@ -276,11 +280,16 @@ def get_organization_message_allowance(organization_id):
|
|||||||
services = dao_get_organization_services(organization_id)
|
services = dao_get_organization_services(organization_id)
|
||||||
|
|
||||||
if not services:
|
if not services:
|
||||||
return jsonify({
|
return (
|
||||||
|
jsonify(
|
||||||
|
{
|
||||||
"messages_sent": 0,
|
"messages_sent": 0,
|
||||||
"messages_remaining": 0,
|
"messages_remaining": 0,
|
||||||
"total_message_limit": 0,
|
"total_message_limit": 0,
|
||||||
}), 200
|
}
|
||||||
|
),
|
||||||
|
200,
|
||||||
|
)
|
||||||
|
|
||||||
current_year = datetime.now(tz=ZoneInfo("UTC")).year
|
current_year = datetime.now(tz=ZoneInfo("UTC")).year
|
||||||
service_ids = [service.id for service in services]
|
service_ids = [service.id for service in services]
|
||||||
@@ -293,8 +302,13 @@ def get_organization_message_allowance(organization_id):
|
|||||||
total_message_limit = sum(s.total_message_limit for s in services)
|
total_message_limit = sum(s.total_message_limit for s in services)
|
||||||
total_messages_remaining = total_message_limit - total_messages_sent
|
total_messages_remaining = total_message_limit - total_messages_sent
|
||||||
|
|
||||||
return jsonify({
|
return (
|
||||||
|
jsonify(
|
||||||
|
{
|
||||||
"messages_sent": total_messages_sent,
|
"messages_sent": total_messages_sent,
|
||||||
"messages_remaining": total_messages_remaining,
|
"messages_remaining": total_messages_remaining,
|
||||||
"total_message_limit": total_message_limit,
|
"total_message_limit": total_message_limit,
|
||||||
}), 200
|
}
|
||||||
|
),
|
||||||
|
200,
|
||||||
|
)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class TokenError(Exception):
|
|||||||
else TOKEN_ERROR_DEFAULT_ERROR_MESSAGE
|
else TOKEN_ERROR_DEFAULT_ERROR_MESSAGE
|
||||||
)
|
)
|
||||||
self.token = token
|
self.token = token
|
||||||
|
super().__init__(self.message, token)
|
||||||
|
|
||||||
|
|
||||||
class TokenExpiredError(TokenError):
|
class TokenExpiredError(TokenError):
|
||||||
@@ -48,6 +49,7 @@ class APIError(Exception):
|
|||||||
def __init__(self, response: Response = None, message: str = None):
|
def __init__(self, response: Response = None, message: str = None):
|
||||||
self.response = response
|
self.response = response
|
||||||
self._message = message
|
self._message = message
|
||||||
|
super().__init__(response, message)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.status_code} - {self.message}"
|
return f"{self.status_code} - {self.message}"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from flask import current_app
|
|||||||
|
|
||||||
class AntivirusError(Exception):
|
class AntivirusError(Exception):
|
||||||
def __init__(self, message=None, status_code=None):
|
def __init__(self, message=None, status_code=None):
|
||||||
|
super().__init__(message, status_code)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.status_code = status_code
|
self.status_code = status_code
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from flask import current_app
|
|||||||
|
|
||||||
class ZendeskError(Exception):
|
class ZendeskError(Exception):
|
||||||
def __init__(self, response):
|
def __init__(self, response):
|
||||||
|
super().__init__(str(response))
|
||||||
self.response = response
|
self.response = response
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Generated
+7
-7
@@ -1,4 +1,4 @@
|
|||||||
# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aiohappyeyeballs"
|
name = "aiohappyeyeballs"
|
||||||
@@ -1527,19 +1527,19 @@ pyflakes = ">=3.4.0,<3.5.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flake8-bugbear"
|
name = "flake8-bugbear"
|
||||||
version = "24.12.12"
|
version = "25.10.21"
|
||||||
description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle."
|
description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle."
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8.1"
|
python-versions = ">=3.10"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "flake8_bugbear-24.12.12-py3-none-any.whl", hash = "sha256:1b6967436f65ca22a42e5373aaa6f2d87966ade9aa38d4baf2a1be550767545e"},
|
{file = "flake8_bugbear-25.10.21-py3-none-any.whl", hash = "sha256:f1c5654f9d9d3e62e90da1f0335551fdbc565c51749713177dbcfb9edb105405"},
|
||||||
{file = "flake8_bugbear-24.12.12.tar.gz", hash = "sha256:46273cef0a6b6ff48ca2d69e472f41420a42a46e24b2a8972e4f0d6733d12a64"},
|
{file = "flake8_bugbear-25.10.21.tar.gz", hash = "sha256:2876afcaed8bfb3464cf33e3ec42cc3bec0a004165b84400dc3392b0547c2714"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
attrs = ">=22.2.0"
|
attrs = ">=22.2.0"
|
||||||
flake8 = ">=6.0.0"
|
flake8 = ">=7.2.0"
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit", "pytest", "tox"]
|
dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit", "pytest", "tox"]
|
||||||
@@ -5926,4 +5926,4 @@ cffi = ["cffi (>=1.17,<2.0) ; platform_python_implementation != \"PyPy\" and pyt
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.1"
|
lock-version = "2.1"
|
||||||
python-versions = "^3.13.2"
|
python-versions = "^3.13.2"
|
||||||
content-hash = "66d1fa0da9127a0c439a29ac4a8fdd83f9d3e9ae5c062a3441c6225ef534eed9"
|
content-hash = "ace53071110003d43f585c505356b2abb531eaf5196ea1669e2ed2ed7ffc9fb3"
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ cyclonedx-python-lib = "^11.4.0"
|
|||||||
cloudfoundry-client = "*"
|
cloudfoundry-client = "*"
|
||||||
exceptiongroup = "==1.3.0"
|
exceptiongroup = "==1.3.0"
|
||||||
flake8 = "^7.3.0"
|
flake8 = "^7.3.0"
|
||||||
flake8-bugbear = "^24.12.12"
|
flake8-bugbear = "^25.10.21"
|
||||||
freezegun = "^1.5.5"
|
freezegun = "^1.5.5"
|
||||||
hypothesis = "^6.142.3"
|
hypothesis = "^6.142.3"
|
||||||
honcho = "*"
|
honcho = "*"
|
||||||
|
|||||||
@@ -963,7 +963,9 @@ def test_get_organization_message_allowance(admin_request, sample_organization,
|
|||||||
mock_get_counts.assert_called_once_with([service_1.id, service_2.id], 2025)
|
mock_get_counts.assert_called_once_with([service_1.id, service_2.id], 2025)
|
||||||
|
|
||||||
|
|
||||||
def test_get_organization_message_allowance_no_services(admin_request, sample_organization):
|
def test_get_organization_message_allowance_no_services(
|
||||||
|
admin_request, sample_organization
|
||||||
|
):
|
||||||
response = admin_request.get(
|
response = admin_request.get(
|
||||||
"organization.get_organization_message_allowance",
|
"organization.get_organization_message_allowance",
|
||||||
organization_id=sample_organization.id,
|
organization_id=sample_organization.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user