def test_integration(self): table = pd.DataFrame({"A": [1, 2], "B": [2, 3]}) result = render( table, { "title": "TITLE", "x_column": "A", "y_columns": [{ "column": "B", "color": "#123456" }], "x_axis_label": "X LABEL", "y_axis_label": "Y LABEL", }, input_columns={ "A": Column("A", "number", "{:,d}"), "B": Column("B", "number", "{:,.2f}"), }, ) assert_frame_equal(result[0], table) self.assertEqual(result[1], "") text = json.dumps(result[2]) # We won't snapshot the chart: that's too brittle. (We change styling # more often than we change logic.) But let's make sure all our # parameters are in the JSON. self.assertIn('"TITLE"', text) self.assertIn('"X LABEL"', text) self.assertIn('"Y LABEL"', text) self.assertIn('"#123456"', text) self.assertRegex(text, r".*:\s*3[,}]")
def test_integration(self): table = pd.DataFrame({'A': [1, 2], 'B': [2, 3]}) result = render(table, { 'title': 'TITLE', 'x_column': 'A', 'y_columns': [{ 'column': 'B', 'color': '#123456' }], 'x_axis_label': 'X LABEL', 'y_axis_label': 'Y LABEL' }, input_columns={ 'A': Column('A', 'number', '{:,d}'), 'B': Column('B', 'number', '{:,.2f}'), }) assert_frame_equal(result[0], table) self.assertEqual(result[1], '') text = json.dumps(result[2]) # We won't snapshot the chart: that's too brittle. (We change styling # more often than we change logic.) But let's make sure all our # parameters are in the JSON. self.assertIn('"TITLE"', text) self.assertIn('"X LABEL"', text) self.assertIn('"Y LABEL"', text) self.assertIn('"#123456"', text) self.assertRegex(text, r'.*:\s*3[,}]')
def test_integration_empty_params(): DefaultParams = { "title": "", "x_axis_label": "", "y_axis_label": "", "x_column": "", "y_columns": [], } table = pd.DataFrame({"A": [1, 2], "B": [2, 3]}) result = render( table, DefaultParams, input_columns={ "A": Column("A", "number", "{:,d}"), "B": Column("B", "number", "{:,.2f}"), }, ) assertResult( result, ( table, i18n_message("noXAxisError.message"), {"error": "Please correct the error in this step's data or parameters"}, ), )
def test_integration_empty_params(self): DefaultParams = { 'title': '', 'x_axis_label': '', 'y_axis_label': '', 'x_column': '', 'y_columns': [], } table = pd.DataFrame({'A': [1, 2], 'B': [2, 3]}) result = render(table, DefaultParams) self.assertResult(result, (table, '', { 'error': 'Please choose an X-axis column' }))
def test_integration_empty_params(self): DefaultParams = { "title": "", "x_axis_label": "", "y_axis_label": "", "x_column": "", "y_columns": [], } table = pd.DataFrame({"A": [1, 2], "B": [2, 3]}) result = render( table, DefaultParams, input_columns={ "A": Column("A", "number", "{:,d}"), "B": Column("B", "number", "{:,.2f}"), }, ) self.assertResult(result, (table, "", { "error": "Please choose an X-axis column" }))
def test_integration(self): table = pd.DataFrame({'A': [1, 2], 'B': [2, 3]}) result = render( table, { 'title': 'TITLE', 'x_column': 'A', 'x_data_type': '0', 'y_columns': '[{"column":"B","color":"#123456"}]', 'x_axis_label': 'X LABEL', 'y_axis_label': 'Y LABEL' }) assert_frame_equal(result[0], table) self.assertEqual(result[1], '') text = json.dumps(result[2]) # We won't snapshot the chart: that's too brittle. (We change styling # more often than we change logic.) But let's make sure all our # parameters are in the JSON. self.assertIn('"TITLE"', text) self.assertIn('"X LABEL"', text) self.assertIn('"Y LABEL"', text) self.assertIn('"#123456"', text) self.assertRegex(text, '.*:\s*3[,}]')
def test_integration_empty_params(self): table = pd.DataFrame({'A': [1, 2], 'B': [2, 3]}) result = render(table, {}) self.assertResult(result, (table, '', { 'error': 'Please choose an X-axis column' }))