Postproc Module#
The Postproc module in the Decide application handles post-processing functionalities. This section provides documentation for the various components within this module.
views.py#
- class postproc.views.PostProcView[source]#
Bases:
APIView
API view for post-processing voting results.
This view provides three types of post-processing: 1. Identity: Keep the votes as is. 2. Text: Post-processing for text-based voting. 3. Weight: Post-processing considering weights for votes.
- Variables:
VOTES_WEIGHT (int) – The default weight for votes.
VOTES_WEIGHT – int
- Method identity:
Post-process voting results with identity transformation.
- Method text:
Post-process text-based voting results.
- Method weight:
Post-process voting results considering weights.
- Method post:
Handle POST requests for post-processing voting results.
- identity(options)[source]#
Post-process voting results with identity transformation.
- Parameters:
options (list) – List of voting options.
- Returns:
Response containing the post-processed results.
- Return type:
Response
- post(request)[source]#
Handle POST requests for post-processing voting results.
The expected request data includes: - ‘type’: IDENTITY | TEXT | WEIGHT - ‘options’: List of voting options. - ‘text_votes’: List of text-based voting results.
- Parameters:
request (Request) – The incoming HTTP request containing post-processing data.
- Returns:
Response containing the post-processed results.
- Return type:
Response
tests.py#
- class postproc.tests.PostProcTestCase[source]#
Bases:
APITestCase
Test case for the PostProc API endpoint.
This test case covers the behavior of the PostProc API endpoint, which performs post-processing on voting results.
- Variables:
client (APIClient) – The Django REST framework API client.
- setUp()[source]#
Set up the test environment before each test method is run.
This method is called before each test method in the test case.
- Returns:
None