def test_Table_with_index_access(self): headers = ['Product', 'Description'] rows = [{ 'cells': ['Gauge', 'Test automation with ease'] }, { 'cells': ['Mingle', 'Agile project management'] }, { 'cells': ['Snap', 'Hosted continuous integration'] }, { 'cells': ['Gocd', 'Continuous delivery platform'] }] proto_table = ProtoTable({'headers': {'cells': headers}, 'rows': rows}) table = Table(proto_table) expected_rows = [row['cells'] for row in rows] for row in expected_rows: self.assertEqual(row, table[expected_rows.index(row)]) for row in table: self.assertTrue(expected_rows.__contains__(row)) with self.assertRaises(IndexError): table.get_row(5)
def test_Table(self): headers = ['Product', 'Description'] rows = [{'cells': ['Gauge', 'Test automation with ease']}, {'cells': ['Mingle', 'Agile project management']}, {'cells': ['Snap', 'Hosted continuous integration']}, {'cells': ['Gocd', 'Continuous delivery platform']}] proto_table = ProtoTable({'headers': {'cells': headers}, 'rows': rows}) table = Table(proto_table) expected_rows = [row['cells'] for row in rows] expected_column_1 = [row['cells'][0] for row in rows] expected_column_2 = [row['cells'][1] for row in rows] self.assertEqual(headers, table.headers) self.assertEqual(expected_rows, table.rows) self.assertEqual(expected_column_1, table.get_column_values_with_index(1)) self.assertEqual(expected_column_2, table.get_column_values_with_index(2)) self.assertEqual(expected_column_1, table.get_column_values_with_name(headers[0])) self.assertEqual(expected_column_2, table.get_column_values_with_name(headers[1])) for row in expected_rows: self.assertEqual(row, table.get_row(expected_rows.index(row) + 1)) with self.assertRaises(IndexError): table.get_row(5)
def test_Table_equality(self): headers = ['Product', 'Description'] rows = [{'cells': ['Gauge', 'Test automation with ease']}, {'cells': ['Mingle', 'Agile project management']}, {'cells': ['Snap', 'Hosted continuous integration']}, {'cells': ['Gocd', 'Continuous delivery platform']}] proto_table = ProtoTable({'headers': {'cells': headers}, 'rows': rows}) table = Table(proto_table) table1 = Table(proto_table) self.assertEqual(table, table1)
def test_Table__str__(self): headers = ['Word', 'Vowel Count'] rows = [{ 'cells': ['Gauge', '3'] }, { 'cells': ['Mingle', '2'] }, { 'cells': ['Snap', '1'] }, { 'cells': ['GoCD', '1'] }, { 'cells': ['Rhythm', '0'] }] proto_table = ProtoTable({'headers': {'cells': headers}, 'rows': rows}) table = Table(proto_table).__str__() self.assertEqual( table, """|Word |Vowel Count| |------|-----------| |Gauge |3 | |Mingle|2 | |Snap |1 | |GoCD |1 | |Rhythm|0 |""")
def _execute_step(request, response, _socket): params = [] for p in request.executeStepRequest.parameters: params.append(Table(p.table) if p.parameterType in [Parameter.Table, Parameter.Special_Table] else p.value) set_response_values(request, response) impl = registry.get_info_for(request.executeStepRequest.parsedStepText).impl execute_method(params, impl, response, registry.is_continue_on_failure)
def test_Table__str__without_rows(self): headers = ['Word', 'Vowel Count'] rows = [] proto_table = ProtoTable({'headers': {'cells': headers}, 'rows': rows}) table = Table(proto_table).__str__() self.assertEqual(table, """|Word|Vowel Count| |----|-----------|""")
def process_execute_step_request(request): params = [] for p in request.parameters: params.append( Table(p.table) if p.parameterType in [Parameter.Table, Parameter.Special_Table] else p.value) response = create_execution_status_response() info = registry.get_info_for(request.parsedStepText) execute_method(params, info, response, registry.is_continue_on_failure) return response
def test_Table_with_index_access(self): headers = ['Product', 'Description'] rows = [{'cells': ['Gauge', 'Test automation with ease']}, {'cells': ['Mingle', 'Agile project management']}, {'cells': ['Snap', 'Hosted continuous integration']}, {'cells': ['Gocd', 'Continuous delivery platform']}] proto_table = ProtoTable({'headers': {'cells': headers}, 'rows': rows}) table = Table(proto_table) expected_rows = [row['cells'] for row in rows] for row in expected_rows: self.assertEqual(row, table[expected_rows.index(row)]) for row in table: self.assertTrue(expected_rows.__contains__(row)) with self.assertRaises(IndexError): table.get_row(5)