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_connection(self):
ds = Datasource.from_file(self.tds_file.name)
self.assertIsInstance(ds.connections[0], Connection)
self.assertIsInstance(ds.connections, list)
def test_can_open_tdsx(self):
ds = Datasource.from_file(self.tdsx_file.name)
self.assertTrue(ds.connections)
self.assertTrue(ds.name)
def test_exception_when_datasource_given_twbx(self):
with self.assertRaises(TableauInvalidFileException):
ds = Datasource.from_file(TABLEAU_10_TWBX)
def test_can_save_tds(self):
original_tds = Datasource.from_file(self.tds_file.name)
original_tds.connections[0].dbname = 'newdb'
original_tds.save()
new_tds = Datasource.from_file(self.tds_file.name)
self.assertEqual(new_tds.connections[0].dbname, 'newdb')
def test_can_extract_datasource_from_file(self):
ds = Datasource.from_file(self.tds_file.name)
self.assertEqual(ds.name, 'sqlserver.17u3bqc16tjtxn14e2hxh19tyvpo')
self.assertEqual(ds.version, '9.3')
def test_can_open_tdsx_and_save_as_changes(self):
new_tdsx_filename = 'newtdsx.tdsx'
original_wb = Datasource.from_file(self.tdsx_file.name)
original_wb.connections[0].server = 'newdb'
original_wb.save_as(new_tdsx_filename)
new_wb = Datasource.from_file(new_tdsx_filename)
self.assertEqual(new_wb.connections[
0].server, 'newdb')
os.unlink(new_tdsx_filename)
def test_can_open_tdsx_and_save_changes(self):
original_tdsx = Datasource.from_file(self.tdsx_file.name)
original_tdsx.connections[0].server = 'newdb'
original_tdsx.save()
new_tdsx = Datasource.from_file(self.tdsx_file.name)
self.assertEqual(new_tdsx.connections[
0].server, 'newdb')
def test_datasource_can_remove_caption(self):
filename = self.get_temp_file('test_datasource_can_remove_caption')
del self.ds.caption
self.ds.save_as(filename)
actual = Datasource.from_file(filename)
self.assertIsNotNone(actual)
self.assertEqual(actual.caption, '')