Skip to content

Commit

Permalink
chore:fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeshmcg committed Oct 23, 2024
1 parent dc70597 commit 938d2a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
14 changes: 4 additions & 10 deletions bc_obps/reporting/tests/api/test_report_version_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def test_unauthorized_users_cannot_post_report_version(self):
assert response.status_code == 401

def test_authorized_users_can_post_updates_to_report_version(self):
report_version = report_version_baker()
report_version = report_version_baker(report_type="Initial Report")

TestUtils.authorize_current_user_as_operator_user(self, operator=report_version.report.operator)

endpoint_under_test = f'/api/reporting/report-version/{report_version.id}/report-operation'
Expand All @@ -54,32 +55,25 @@ def test_authorized_users_can_post_updates_to_report_version(self):
"activities": [],
"regulated_products": [],
"operation_representative_name": "new operation representative name",
"operation_report_type": "LFO", # This belongs to ReportVersion, not ReportOperation
"operation_report_type": "Annual Report",
}

# Assert changes for ReportOperation fields
assert report_version.report_operation.operator_legal_name != data['operator_legal_name']
assert report_version.report_operation.operator_trade_name != data['operator_trade_name']
assert report_version.report_operation.operation_name != data['operation_name']
assert report_version.report_operation.operation_bcghgid != data['operation_bcghgid']
assert report_version.report_operation.bc_obps_regulated_operation_id != data['bc_obps_regulated_operation_id']
assert report_version.report_operation.operation_representative_name != data['operation_representative_name']

# Assert change for ReportVersion field
assert report_version.report_type != data['operation_report_type'] # Correctly assert for ReportVersion
assert report_version.report_type != data['operation_report_type']

response = TestUtils.mock_post_with_auth_role(
self, 'industry_user', self.content_type, data, endpoint_under_test
)

assert response.status_code == 201
response_json = response.json()

# Assert response for ReportOperation fields
assert response_json['operator_legal_name'] == data['operator_legal_name']
assert response_json['operator_trade_name'] == data['operator_trade_name']
assert response_json['operation_name'] == data['operation_name']
assert response_json['operation_bcghgid'] == data['operation_bcghgid']
assert response_json['bc_obps_regulated_operation_id'] == data['bc_obps_regulated_operation_id']
assert response_json['operation_representative_name'] == data['operation_representative_name']

1 change: 1 addition & 0 deletions bc_obps/reporting/tests/models/test_report_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def setUpTestData(cls):
*TIMESTAMP_COMMON_FIELDS,
("id", "ID", None, None),
("report", "report", None, None),
("report_type", "report type", None, None),
("is_latest_submitted", "is latest submitted", None, None),
("status", "status", 1000, None),
("facility_reports", "facility report", None, 0),
Expand Down

0 comments on commit 938d2a4

Please sign in to comment.