Visualizer Module#

The Visualizer module is responsible for presenting visual representations of data. This section documents the various components of the Visualizer module.

views.py#

class visualizer.views.VisualizerView[source]#

Bases: TemplateView

View for visualizing voting data.

This view renders a template for visualizing voting statistics, including the number of census entries, votes, and participation rate.

Variables:

template_name (str) – The name of the template to render.

get_context_data(**kwargs)[source]#

Retrieve the context data for rendering the template.

Retrieves information about a specific voting instance, including the number of census entries, votes, and participation rate.

Parameters:

kwargs (dict) – Keyword arguments.

Returns:

A dictionary containing context data for the template.

Return type:

dict

Raises:

Http404 – If an error occurs while retrieving or processing the voting data.

template_name = 'visualizer/visualizer.html'#

test_selenium.py#

class visualizer.test_selenium.VisualizerTestCase[source]#

Bases: StaticLiveServerTestCase

Test case for the Visualizer functionality.

This test case includes methods to create various types of votings, simulate user participation, and check the visualization results.

Variables:
  • base – An instance of BaseTestCase for common test setup.

  • driver – The Selenium WebDriver instance for browser automation.

create_classic_voting()[source]#

Create and return a classic voting with a test question and options.

Returns:

The created Voting instance.

Return type:

Voting

create_comment_voting_started()[source]#

Create and return a comment voting with a test question and set the start date.

Returns:

The created Voting instance.

Return type:

Voting

create_multiple_choice_voting_started()[source]#

Create and return a multiple-choice voting with a test question and options, and set the start date.

Returns:

The created Voting instance.

Return type:

Voting

create_preference_voting_started()[source]#

Create and return a preference voting with a test question and options, and set the start date.

Returns:

The created Voting instance.

Return type:

Voting

create_yesno_voting_started()[source]#

Create and return a Yes/No voting with a test question and options, and set the start date.

Returns:

The created Voting instance.

Return type:

Voting

setUp()[source]#

Set up the test environment.

Initialize BaseTestCase and create a headless Chrome WebDriver.

Returns:

None

tearDown()[source]#

Tear down the test environment.

Quit the WebDriver and call the tearDown method of the base class.

Returns:

None

test_visualizer_census_change()[source]#

Test the visualization when the census changes.

Create a voting with a test question and options, access the visualization page, record the census information, add new voters, and check if the census information changes.

Returns:

None

test_visualizer_classic_finished()[source]#

Test the visualization for a finished classic voting.

Create a classic voting with a test question, set start and end dates, access the visualization page, and check various chart options.

Returns:

None

test_visualizer_comment_finished()[source]#

Test the visualization for a finished comment voting.

Create a comment voting with a test question, set start and end dates, access the visualization page, and check if there are no select elements.

Returns:

None

test_visualizer_multiple_choice_finished()[source]#

Test the visualization for a finished multiple-choice voting.

Create a multiple-choice voting with a test question, set start and end dates, access the visualization page, and check various chart options.

Returns:

None

test_visualizer_not_started()[source]#

Test the visualization when the voting is not started.

Access the visualization page, check the voting state, and assert that it is not started.

Returns:

None

test_visualizer_preference_finished()[source]#

Test the visualization for a finished preference voting.

Create a preference voting with a test question, set start and end dates, access the visualization page, and check various chart options.

Returns:

None

test_visualizer_started_classic_with_census()[source]#

Test the visualization for a classic voting with a census.

Create a classic voting with a test question, add voters to the census, access the visualization page, and check the participation percentage.

Returns:

None

test_visualizer_started_comment_with_census()[source]#

Test the visualization for a comment voting with a census.

Create a comment voting with a test question, add voters to the census, access the visualization page, and check the participation percentage.

Returns:

None

test_visualizer_started_multiple_choice_with_census()[source]#

Test the visualization for a multiple-choice voting with a census.

Create a multiple-choice voting with a test question, add voters to the census, access the visualization page, and check the participation percentage.

Returns:

None

test_visualizer_started_no_census()[source]#

Test the visualization when the voting is started but there is no census.

Create a voting with a test question and options, set the start date, access the visualization page, and check the participation information.

Returns:

None

test_visualizer_started_preference_with_census()[source]#

Test the visualization for a preference voting with a census.

Create a preference voting with a test question, add voters to the census, access the visualization page, and check the participation percentage.

Returns:

None

test_visualizer_started_yesno_with_census()[source]#

Test the visualization for a Yes/No voting with a census.

Create a Yes/No voting with a test question, add voters to the census, access the visualization page, and check the participation percentage.

Returns:

None

test_visualizer_yesno_finished()[source]#

Test the visualization for a finished Yes/No voting.

Create a Yes/No voting with a test question, set start and end dates, access the visualization page, and check the chart options.

Returns:

None