def run_line_graph_scenarios(chart_builder_page, driver): """ CHART BUILDER CAN BUILD LINE GRAPHS """ """ GIVEN some basic data appropriate for building line graphs """ chart_builder_page.refresh() inject_data(driver, ethnicity_by_time_data) chart_builder_page.click_data_okay() """ WHEN we add basic line chart settings """ chart_builder_page.select_chart_type("Line graph") chart_builder_page.wait_for_seconds(1) chart_builder_page.select_line_x_axis_column("Time") chart_builder_page.wait_for_seconds(1) """ THEN a line graph exists with times on the x-axis and ethnicity names as the series """ times = chart_builder_page.chart_x_axis() assert times == ["1", "2", "3"] ethnicities = chart_builder_page.graph_series() assert ethnicities == ["Asian", "Black", "Mixed", "White", "Other"] """ CHART BUILDER ORDERS LINE GRAPH SERIES according to classifications """ """ GIVEN some shuffled up data appropriate for building line graphs """ chart_builder_page.refresh() inject_data(driver, shuffle_table(ethnicity_by_time_data)) chart_builder_page.click_data_okay() """ WHEN we add basic line chart settings """ chart_builder_page.select_chart_type("Line graph") chart_builder_page.wait_for_seconds(1) chart_builder_page.select_line_x_axis_column("Time") chart_builder_page.wait_for_seconds(1) """ THEN ethnicities are ordered as the series """ ethnicities = chart_builder_page.graph_series() assert ethnicities == ["Asian", "Black", "Mixed", "White", "Other"]
def run_bar_chart_scenarios(chart_builder_page, driver): """ SCENARIO 1. CREATE A SIMPLE CHART """ """ GIVEN some basic data appropriate for building bar charts """ inject_data(driver, simple_data) chart_builder_page.click_data_okay() chart_builder_page.wait_for_seconds(1) """ THEN the edit screen should get set up """ assert chart_builder_page.source_contains("5 rows by 2 columns") assert len(chart_builder_page.get_ethnicity_settings_list()) == 3 assert chart_builder_page.get_ethnicity_settings_value() == "ONS 2011 - 5+1" """ WHEN we select bar chart """ chart_builder_page.select_chart_type("Bar chart") chart_builder_page.wait_for_seconds(1) """ THEN we should have a chart with ethnicities as the bars """ ethnicities = chart_builder_page.chart_x_axis() assert ethnicities == ["Asian", "Black", "Mixed", "White", "Other"] values = chart_builder_page.chart_labels() assert values == ["5", "4", "3", "2", "1"] """ WHEN we select an alternative ethnicity set up """ chart_builder_page.select_ethnicity_settings("ONS 2001 - 5+1") chart_builder_page.wait_for_seconds(1) """ THEN the ethnicities that appear in the charts get changed """ ethnicities = chart_builder_page.chart_x_axis() assert ethnicities == ["Asian", "Black", "Mixed", "White", "Other inc Chinese"] """ SCENARIO 2. CREATE A CHART WITH DISORDERLY DATA """ """ GIVEN a shuffled version of our simple data """ chart_builder_page.refresh() inject_data(driver, shuffle_table(simple_data)) chart_builder_page.click_data_okay() """ WHEN we select bar chart """ chart_builder_page.select_chart_type("Bar chart") chart_builder_page.wait_for_seconds(1) """ THEN the ethnicities are correctly sorted automatically """ ethnicities = chart_builder_page.chart_x_axis() assert ethnicities == ["Asian", "Black", "Mixed", "White", "Other"] return chart_builder_page
def run_simple_table_scenarios(table_builder_page, driver): """ SCENARIO 1. CREATE A SIMPLE TABLE """ """ GIVEN some basic data appropriate for building simple tables """ inject_data(driver, simple_data) table_builder_page.click_data_okay() table_builder_page.wait_for_seconds(1) """ THEN the edit screen should get set up """ assert table_builder_page.source_contains("5 rows by 2 columns") assert len(table_builder_page.get_ethnicity_settings_list()) == 3 assert table_builder_page.get_ethnicity_settings_value( ) == "ONS 2011 - 5+1" assert table_builder_page.input_index_column_name() == "Ethnicity" """ THEN we select the column to display """ table_builder_page.select_column(1, "Value") table_builder_page.wait_for_seconds(1) """ THEN we should have a table with appropriate headers """ assert table_builder_page.table_headers() == ["Ethnicity", "Value"] assert table_builder_page.table_index_column_name() == "Ethnicity" """ AND we should have a table with appropriate column values """ assert table_builder_page.table_column_contents(1) == [ "Asian", "Black", "Mixed", "White", "Other" ] assert table_builder_page.table_column_contents(2) == [ "5", "4", "3", "2", "1" ] """ WHEN we select an alternative ethnicity set up """ table_builder_page.select_ethnicity_settings_value("ONS 2001 - 5+1") table_builder_page.wait_for_seconds(1) """ THEN the ethnicities that appear in the tables get changed """ assert table_builder_page.table_column_contents(1) == [ "Asian", "Black", "Mixed", "White", "Other inc Chinese" ] """ WHEN we select an alternative first column name """ table_builder_page.set_input_index_column_name("Custom first column") table_builder_page.wait_for_seconds(1) """ THEN the first column name in the table is changed """ assert table_builder_page.table_index_column_name( ) == "Custom first column" """ SCENARIO 2. CREATE A CHART WITH DISORDERLY DATA """ """ GIVEN a shuffled version of our simple data """ table_builder_page.refresh() inject_data(driver, shuffle_table(simple_data)) table_builder_page.click_data_okay() """ THEN we select the column to display """ table_builder_page.select_column(1, "Value") table_builder_page.wait_for_seconds(1) """ THEN the ethnicities are correctly sorted automatically """ assert table_builder_page.table_column_contents(1) == [ "Asian", "Black", "Mixed", "White", "Other" ] return table_builder_page