Skip to content

Commit

Permalink
ProgressInfo DDL test
Browse files Browse the repository at this point in the history
  • Loading branch information
xzkostyan committed Jul 29, 2019
1 parent 6b6148a commit 48d09ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
7 changes: 4 additions & 3 deletions clickhouse_driver/result.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .blockstreamprofileinfo import BlockStreamProfileInfo
from .progress import Progress


Expand Down Expand Up @@ -131,9 +132,9 @@ def next(self):

class QueryInfo(object):
def __init__(self):
self.profile_info = None
self.progress = None
self.elapsed = None
self.profile_info = BlockStreamProfileInfo()
self.progress = Progress()
self.elapsed = 0

def store_profile(self, profile_info):
self.profile_info = profile_info
Expand Down
26 changes: 20 additions & 6 deletions tests/test_query_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_store_last_query_after_execute(self):
assert last_query.progress.bytes == 42
assert last_query.progress.total_rows == 0

assert last_query.elapsed >= 0
assert last_query.elapsed > 0

def test_last_query_after_execute_iter(self):
with self.sample_table():
Expand All @@ -51,7 +51,7 @@ def test_last_query_after_execute_iter(self):
assert last_query.progress.bytes == 42
assert last_query.progress.total_rows == 0

assert last_query.elapsed is None
assert last_query.elapsed == 0

def test_last_query_after_execute_with_progress(self):
with self.sample_table():
Expand All @@ -69,7 +69,7 @@ def test_last_query_after_execute_with_progress(self):
assert last_query.progress.bytes == 42
assert last_query.progress.total_rows == 0

assert last_query.elapsed is None
assert last_query.elapsed == 0

def test_last_query_progress_total_rows(self):
self.client.execute('SELECT max(number) FROM numbers(10)')
Expand All @@ -87,7 +87,7 @@ def test_last_query_progress_total_rows(self):
total_rows = 10 if current > (19, 4) else 0
assert last_query.progress.total_rows == total_rows

assert last_query.elapsed >= 0
assert last_query.elapsed > 0

def test_last_query_after_execute_insert(self):
with self.sample_table():
Expand All @@ -96,8 +96,11 @@ def test_last_query_after_execute_insert(self):

last_query = self.client.last_query
assert last_query is not None
assert last_query.progress is None
assert last_query.elapsed >= 0
assert last_query.progress is not None
assert last_query.progress.rows == 0
assert last_query.progress.bytes == 0

assert last_query.elapsed > 0

def test_override_after_subsequent_queries(self):
query = 'SELECT * FROM test WHERE foo < %(i)s ORDER BY foo LIMIT 5'
Expand Down Expand Up @@ -138,3 +141,14 @@ def test_progress_info_increment(self):
current = self.client.connection.server_info.version_tuple()
total_rows = 100000000 if current > (19, 4) else 0
assert last_query.progress.total_rows == total_rows

def test_progress_info_ddl(self):
self.client.execute('DROP TABLE IF EXISTS foo')

last_query = self.client.last_query
assert last_query is not None
assert last_query.progress is not None
assert last_query.progress.rows == 0
assert last_query.progress.bytes == 0

assert last_query.elapsed > 0

0 comments on commit 48d09ce

Please sign in to comment.