A platform, 'Traffic-Violation-Report-System', enabling users in Taiwan to upload and share responses from law enforcement to traffic violations. This system aims for greater transparency in traffic law enforcement. It utilises Django for backend and Flutter for a separated frontend web development.
GNU Affero General Public License v3.0
0
stars
0
forks
source link
[Sweep Rules] Add Unit Tests for New Business Logic in Report Service #124
"All new business logic should have corresponding unit tests."
Description
This PR adds unit tests for the new business logic introduced in the getReports method of the lib/services/report_service.dart file. The getReports method retrieves traffic violation reports and returns a list of TrafficViolation objects. The unit tests ensure the correctness of this method by testing different scenarios, including successful retrieval of reports and handling of error responses.
Summary of Changes
Created a new file test/services/report_service_test.dart to add unit tests for the getReports method.
Modified the test/services/report_service_test.dart file to import necessary classes and functions from the lib/services/report_service.dart file.
Added a new test case for the getReports method to verify the functionality of retrieving reports and mapping them to TrafficViolation objects.
Added a new test case to handle the scenario when the response status code is not 200 in the getReports method.
Added a new test case for the getViolation method to verify the functionality of retrieving a specific traffic violation report.
Added a new test case to handle the scenario when the response status code is not 200 in the getViolation method.
These changes ensure that the new business logic in the getReports method is thoroughly tested and that the codebase maintains a high level of test coverage.
Please review and merge this PR once the tests pass successfully.
PR Feedback (click)
I created this PR to address this rule:
"All new business logic should have corresponding unit tests."
Description
This PR adds unit tests for the new business logic introduced in the
getReports
method of thelib/services/report_service.dart
file. ThegetReports
method retrieves traffic violation reports and returns a list ofTrafficViolation
objects. The unit tests ensure the correctness of this method by testing different scenarios, including successful retrieval of reports and handling of error responses.Summary of Changes
test/services/report_service_test.dart
to add unit tests for thegetReports
method.test/services/report_service_test.dart
file to import necessary classes and functions from thelib/services/report_service.dart
file.getReports
method to verify the functionality of retrieving reports and mapping them toTrafficViolation
objects.getReports
method.getViolation
method to verify the functionality of retrieving a specific traffic violation report.getViolation
method.These changes ensure that the new business logic in the
getReports
method is thoroughly tested and that the codebase maintains a high level of test coverage.Please review and merge this PR once the tests pass successfully.
Thank you!