Skip to content

Commit 9653e07

Browse files
committed
chore: some suggestions from copilot
1 parent 3154fcd commit 9653e07

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

bc_obps/common/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class UserError(Exception):
77
pass
88

99

10-
class SystemError(Exception):
10+
class InternalSystemError(Exception):
1111
"""
12-
Base class for system-related errors.
12+
Base class for obps system-related errors.
1313
These errors are typically used for unexpected conditions that indicate a problem in either
1414
unforeseen manipulation of the system, or a bug in the code.
1515
"""

bc_obps/reporting/service/report_validation/validators/reporting_configuration_validator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from common.exceptions import InternalSystemError
12
from django.contrib.postgres.aggregates import ArrayAgg
23
from django.db.models import OuterRef, QuerySet
34
from reporting.models.configuration_element import ConfigurationElement
@@ -33,7 +34,7 @@ def validate_configuration_elements_present(report_version: ReportVersion) -> di
3334
)
3435

3536
if missing_config.exists():
36-
raise SystemError(
37+
raise InternalSystemError(
3738
f"Missing configuration elements for report methodology IDs: {str.join(', ', [str(m['id']) for m in missing_config])}"
3839
)
3940

@@ -71,7 +72,7 @@ def validate(report_version: ReportVersion) -> dict[str, ReportValidationError]:
7172
Validator ensuring that all the activity data reported has a matching configuration
7273
defined for the reporting year of the report.
7374
74-
For each ReportMethodlogy record:
75+
For each ReportMethodology record:
7576
- Collect ReportMethodology -> ReportEmission (Gas Type) -> ReportSourceType -> ReportActivity -> Report (Reporting Year)
7677
- Validate that there is a ConfigurationElement record matching that combination
7778
- Validate that the extra reporting fields reported are in that configuration element

bc_obps/reporting/tests/service/report_validation/validators/test_reporting_configuration_validator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from common.exceptions import InternalSystemError
12
from model_bakery.baker import make, make_recipe, prepare_recipe
23
import pytest
34
from reporting.models.configuration_element import ConfigurationElement
@@ -53,7 +54,7 @@ def test_raises_if_configuration_doesnt_match_reporting_year(self):
5354
)
5455

5556
with pytest.raises(
56-
SystemError,
57+
InternalSystemError,
5758
match=f"Missing configuration elements for report methodology IDs: {report_methodology.id}",
5859
):
5960
self.validator_under_test.validate(self.report_version)
@@ -76,7 +77,7 @@ def test_raises_if_configuration_doesnt_match_activity(self):
7677
)
7778

7879
with pytest.raises(
79-
SystemError,
80+
InternalSystemError,
8081
match=f"Missing configuration elements for report methodology IDs: {report_methodology.id}",
8182
):
8283
self.validator_under_test.validate(self.report_version)
@@ -100,7 +101,7 @@ def test_raises_if_reported_fields_not_allowed_in_configuration_element(self):
100101
)
101102

102103
with pytest.raises(
103-
SystemError,
104+
InternalSystemError,
104105
match=f"ReportMethodology ID {report_methodology.id} has reporting fields"
105106
" {'unexpectedField'} which are not in the allowed fields {'allowedField'} of its matching configuration element.",
106107
):

0 commit comments

Comments
 (0)