def test_join_tiny(self): """Tests that join properly handles table data ranges that look like vectors / scalars""" key_a = self.workbook.get("tiny_k_2") key_b = self.workbook.get("tiny_k_1") xl.join(key_a, key_b) a_joined = self.workbook.range("E1:E2") self.assertEqual(a_joined.get(), [u"tiny_v_1", 1.0])
def test_join_single_column(self): """Tests that a single column can be joined to an existing table""" zip_key_a = self.workbook.get("B:B") zip_key_b = self.workbook.get("D1:D50") zip_cities = self.workbook.get("E1:E50") self.assertEqual(zip_cities.get(), ['Redmond', 'Austin', None]) self.assertEqual(zip_key_a.get(), [78705.0, 98052.0, 0.0]) self.assertEqual(zip_key_b.get(), [98052.0, 78705.0, None]) xl.join(zip_key_a, zip_key_b) # We fetch these ranges here, because they aren't durable under insertion # (the join would have shifted them to the right) # We use range so that we don't snap to the table data joined_cities_header = self.workbook.range("C1:C1") self.assertEqual(joined_cities_header.get(), "CityName") # Should snap to joined column data joined_cities_data = self.workbook.get("C:C") self.assertEqual(joined_cities_data.get(), ['Austin', 'Redmond', None])
def test_join_multi_column(self): """Tests that multiple columns can be joined to an existing table""" key_a = self.workbook.get("D3:D5") key_b = self.workbook.get("H3:H5") xl.join(key_a, key_b) # We fetch these ranges here, because they aren't durable under insertion # (the join would have shifted them to the right) # We use range so that we don't snap to the table data # First, check that both columns (excl. key) from table b made it to table a, and table a headers are intact a_cols_headers = self.workbook.range("C2:G2") self.assertEqual(a_cols_headers.get(), [u'a_1', u'key', u'a_2', u'b_1', u'b_2']) # Data in the joined columns a_joined_data = self.workbook.get("F3:G5") # $$$ get() is inconsistent, as of writing, about using tuples or lists. normalize a_joined_data_lists = [list(r) for r in a_joined_data.get()] self.assertEqual(a_joined_data_lists, [[None, None], [u'b_1_1', u'b_2_1'], [u'b_1_4', u'b_2_4']])
def test_join_single_column(self): """Tests that a single column can be joined to an existing table""" zip_key_a = self.workbook.get("B:B") zip_key_b = self.workbook.get("D1:D50") zip_cities = self.workbook.get("E1:E50") self.assertEqual(zip_cities.get(), [u'Redmond', u'Austin', None]) self.assertEqual(zip_key_a.get(), [78705.0, 98052.0, 0.0]) self.assertEqual(zip_key_b.get(), [98052.0, 78705.0, None]) xl.join(zip_key_a, zip_key_b) # We fetch these ranges here, because they aren't durable under insertion # (the join would have shifted them to the right) # We use range so that we don't snap to the table data joined_cities_header = self.workbook.range("C1:C1") self.assertEqual(joined_cities_header.get(), "CityName") # Should snap to joined column data joined_cities_data = self.workbook.get("C:C") self.assertEqual(joined_cities_data.get(), [u'Austin', u'Redmond', None])
def test_big_join(self): source_key = self.workbook.get("bigjoin_key_1") dest_key = self.workbook.get("bigjoin_key_2") xl.join(dest_key, source_key) self.assertEqual( self.workbook.get("G2:H2").get(), [u"key_3222", u"val_3222"])
def test_big_join(self): source_key = self.workbook.get("bigjoin_key_1") dest_key = self.workbook.get("bigjoin_key_2") xl.join(dest_key, source_key) self.assertEqual( self.workbook.get("G2:H2").get(), [u"key_3222", u"val_3222"] )