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_bad_dbclass_rasies_attribute_error(self):
conn = Connection(self.connection)
conn.dbclass = 'sqlserver'
self.assertEqual(conn.dbclass, 'sqlserver')
with self.assertRaises(AttributeError):
conn.dbclass = 'NotReal'
def test_can_delete_port_from_connection(self):
conn = Connection(self.connection)
conn.port = None
self.assertEqual(conn.port, None)
self.assertIsNone(conn._connectionXML.get('port'))
def test_can_extract_federated_connections(self):
parser = ConnectionParser(ET.parse(TABLEAU_10_TDS), '10.0')
connections = parser.get_connections()
self.assertIsInstance(connections, list)
self.assertIsInstance(connections[0], Connection)
self.assertEqual(connections[0].dbname, 'TestV1')
def test_can_delete_port_from_connection(self):
conn = Connection(self.connection)
conn.port = None
self.assertEqual(conn.port, None)
self.assertIsNone(conn._connectionXML.get('port'))
def test_can_read_attributes_from_connection(self):
conn = Connection(self.connection)
self.assertEqual(conn.dbname, 'TestV1')
self.assertEqual(conn.username, '')
self.assertEqual(conn.server, 'mssql2012')
self.assertEqual(conn.dbclass, 'sqlserver')
self.assertEqual(conn.authentication, 'sspi')
self.assertEqual(conn.port, '1433')
def test_can_extract_federated_connections(self):
parser = ConnectionParser(ET.parse(TABLEAU_10_TDS), '10.0')
connections = parser.get_connections()
self.assertIsInstance(connections, list)
self.assertIsInstance(connections[0], Connection)
self.assertEqual(connections[0].dbname, 'TestV1')
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_delete_initial_sql_from_connection(self):
conn = Connection(self.connection)
conn.initial_sql = None
self.assertEqual(conn.initial_sql, None)
self.assertIsNone(conn._connectionXML.get('initial_sql'))
def _extract_federated_connections(self):
connections = list(map(Connection, self._dsxml.findall('.//named-connections/named-connection/*')))
# 'sqlproxy' connections (Tableau Server Connections) are not embedded into named-connection elements
# extract them manually for now
connections.extend(map(Connection, self._dsxml.findall("./connection[@class='sqlproxy']")))
return connections