class TestClientQuery(unittest.TestCase): def setUp(self): self.dummy_client = Client('dummy', filename='test.csv') self.csv_client = Client('csv', filename='test.csv') self.sqlite_client = Client('sqlite', filename='test.sqlite') def test_csv(self): self.csv_client.query() self.csv_client.query("SELECT * FROM test LIMIT 1;") def test_sqlite(self): self.sqlite_client.query("SELECT * FROM test LIMIT 1;") def test_dummy(self): self.dummy_client.query() self.dummy_client.query("SELECT * FROM test LIMIT 1;")
def __init__(self, database_type, credentials=None, filename=None, label_extractor=None, client=None, query=None, results=None): '''set object data and connect with the service''' self.query = query if results: self.results_fname = results else: self.results_fname = 'results.json' if not client: client = Client(database_type, credentials, filename) self.client = client # allows the user to specify a script to get the ground truth if label_extractor is not None: try: self.get_row_label = importlib.import_module( label_extractor).get_row_label except: print("could not import function get_row_label, using default") self.get_row_label = self._make_indices_list try: self.get_row_value = importlib.import_module( label_extractor).get_row_value except: print("could not import function get_row_value, using default") self.get_row_value = self._serialize_values else: self.get_row_label = self._make_indices_list
def setUp(self): self.dummy_client = Client('dummy', filename='test.csv') self.csv_client = Client('csv', filename='test.csv') self.sqlite_client = Client('sqlite', filename='test.sqlite')
def test_nonexistant(self): with self.assertRaises(Exception): client = Client("dne")
def test_dummy(self): client = Client('dummy')
def test_sqlite(self): with self.assertRaises(Exception): client = Client('sqlite') client = Client('sqlite', filename='test.sqlite')
def test_csv(self): with self.assertRaises(Exception): client = Client('csv') client = Client('csv', filename='test.csv')