Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_can_extract_datasourceV10(self):
wb = Workbook(self.workbook_file.name)
self.assertEqual(len(wb.datasources), 1)
self.assertEqual(len(wb.datasources[0].connections), 2)
self.assertIsInstance(wb.datasources[0].connections, list)
self.assertIsInstance(wb.datasources[0], Datasource)
self.assertEqual(wb.datasources[0].name,
'federated.1s4nxn20cywkdv13ql0yk0g1mpdx')
def test_can_get_worksheets(self):
wb = Workbook(self.workbook_file.name)
self.assertIsNotNone(wb.worksheets)
def test_can_get_worksheets(self):
wb = Workbook(self.workbook_file.name)
self.assertIsNotNone(wb.worksheets)
def test_can_open_twbx_and_save_changes(self):
original_wb = Workbook(self.workbook_file.name)
original_wb.datasources[0].connections[0].server = 'newdb'
original_wb.save()
new_wb = Workbook(self.workbook_file.name)
self.assertEqual(new_wb.datasources[0].connections[
0].server, 'newdb')
def test_has_filename(self):
wb = Workbook(self.workbook_file.name)
self.assertEqual(wb.filename, self.workbook_file.name)
def test_save_has_xml_declaration(self):
original_wb = Workbook(self.workbook_file.name)
original_wb.datasources[0].connections[0].dbname = 'newdb'
original_wb.save()
with open(self.workbook_file.name) as f:
first_line = f.readline().strip() # first line should be xml tag
self.assertEqual(
first_line, "")
def setUp(self):
self.wb = Workbook(TEST_TWB_FILE)
# Assume the first datasource in the file
self.ds = self.wb.datasources[0]
def test_can_update_datasource_connection_and_saveV10(self):
original_wb = Workbook(self.workbook_file.name)
original_wb.datasources[0].connections[0].dbname = 'newdb'
original_wb.save()
new_wb = Workbook(self.workbook_file.name)
self.assertEqual(new_wb.datasources[0].connections[
0].dbname, 'newdb')
def test_exception_when_workbook_given_tdsx(self):
with self.assertRaises(TableauInvalidFileException):
wb = Workbook(TABLEAU_10_TDSX)
def test_can_open_twbx_and_save_as_changes(self):
new_twbx_filename = 'newtwbx.twbx'
original_wb = Workbook(self.workbook_file.name)
original_wb.datasources[0].connections[0].server = 'newdb'
original_wb.save_as(new_twbx_filename)
new_wb = Workbook(new_twbx_filename)
self.assertEqual(new_wb.datasources[0].connections[
0].server, 'newdb')
os.unlink(new_twbx_filename)