Merge branch 'master' into PyKusto-9-Implement-parse_json

This commit is contained in:
Shai Keren 2019-12-29 18:42:09 +02:00
Родитель 914651cdf3 a6f85c8015
Коммит 303558e7cc
5 изменённых файлов: 25 добавлений и 6 удалений

Просмотреть файл

@ -1,5 +1,6 @@
import logging
import sys
from typing import Callable
from unittest import TestCase
from pykusto.utils import logger
@ -16,3 +17,19 @@ class TestBase(TestCase):
def setUp(self):
logger.info("Running test: " + self._testMethodName)
def assertRaises(self, expected_exception: BaseException, test_callable: Callable, *args, **kwargs):
"""
This method overrides the one in `unittest.case.TestCase`.
Instead of providing it with an exception type, you provide it with an exception instance that contains
the expected message.
"""
expected_exception_type = type(expected_exception)
expected_exception_message = str(expected_exception)
with super().assertRaises(expected_exception_type) as cm:
test_callable(*args, **kwargs)
self.assertEqual(
expected_exception_message,
str(cm.exception)
)

Просмотреть файл

@ -70,7 +70,7 @@ class TestExpressions(TestBase):
def test_method_does_not_exist(self):
self.assertRaises(
AttributeError,
AttributeError("No such method: non_existant_method"),
col.foo.non_existant_method,
)

Просмотреть файл

@ -1,4 +1,5 @@
import datetime
import unittest
from pykusto import functions as f
from pykusto.expressions import column_generator as col
@ -484,6 +485,7 @@ class TestFunction(TestBase):
Query().summarize(f.arg_min(col.foo, col.bar, col.fam)).render()
)
@unittest.skip("Re-enable once issue #1 is resolved")
def test_avg(self):
self.assertEqual(
" | summarize avg(foo)",

Просмотреть файл

@ -137,14 +137,14 @@ class TestQuery(TestBase):
def test_join_no_joined_table(self):
self.assertRaises(
JoinException,
JoinException("The joined query must have a table"),
Query().where(col.foo > 4).take(5).join(
Query().take(2), kind=JoinKind.INNER).on(col.col0).on(col.col1, col.col2).render
)
def test_join_no_on(self):
self.assertRaises(
JoinException,
JoinException("A call to join() must be followed by a call to on()"),
Query().where(col.foo > 4).take(5).join(
Query().take(2), kind=JoinKind.INNER).render
)
@ -201,7 +201,7 @@ class TestQuery(TestBase):
def test_mv_expand_no_args(self):
self.assertRaises(
ValueError,
ValueError("Please specify one or more columns for mv-expand"),
Query().mv_expand
)

Просмотреть файл

@ -34,7 +34,7 @@ class TestTable(TestBase):
def test_execute_no_table(self):
self.assertRaises(
RuntimeError,
RuntimeError("No table supplied"),
Query().take(5).execute
)
@ -43,7 +43,7 @@ class TestTable(TestBase):
table = PyKustoClient(mock_kusto_client)['test_db']['test_table']
self.assertRaises(
RuntimeError,
RuntimeError("This table is already bound to a query"),
Query(table).take(5).execute,
table
)