예제 #1
0
def test_client_context():
    with patch.object(Client, "_fetch_query_engine", return_value=MagicMock()):
        with Client(apikey="APIKEY",
                    endpoint="ENDPOINT",
                    database="sample_datasets") as client:
            client.close = MagicMock()
            client.close.assert_not_called()
        client.close.assert_called_with()
예제 #2
0
    def setUp(self, fetch_query_engine):
        self.client = Client(apikey='APIKEY', endpoint='ENDPOINT', database='sample_datasets')

        self.assertTrue(fetch_query_engine.called)
        self.client.engine = MagicMock()

        res = {'columns': ['col1', 'col2'], 'data': [[1, 'a'], [2, 'b']]}
        self.client.engine.execute = MagicMock(return_value=res)
예제 #3
0
    def setUp(self, fetch_query_engine):
        self.client = Client(apikey="APIKEY",
                             endpoint="ENDPOINT",
                             database="sample_datasets")
        self.assertEqual(self.client.apikey, "APIKEY")
        self.assertEqual(self.client.endpoint, "ENDPOINT")
        self.assertEqual(self.client.database, "sample_datasets")

        self.assertTrue(fetch_query_engine.called)
        self.client.default_engine = MagicMock()
        self.client.api_client = MagicMock()

        res = {"columns": ["col1", "col2"], "data": [[1, "a"], [2, "b"]]}
        self.client.default_engine.execute = MagicMock(return_value=res)
예제 #4
0
def test_client_context():
    with patch.object(Client, '_fetch_query_engine', return_value=MagicMock()):
        with Client(apikey='APIKEY', endpoint='ENDPOINT', database='sample_datasets') as client:
            client.close = MagicMock()
            client.close.assert_not_called()
        client.close.assert_called_with()