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_select_from_dict(self):
select = Select.from_dict(create_hits())
print(select)
print(repr(select))
self.assertIsNotNone(select.result)
self.assertEqual(len(select), 3)
def test_select_explain_result(self):
select = Select()
select._result_dict = create_hits()
select.explain_result()
print(select)
print(repr(select))
self.assertIsNotNone(select.result)
self.assertEqual(len(select), 3)
def test_collect(self):
query = Select()
query._values = [{'a': 1}, {'a': 2}]
self.assertEqual(query.collect(), [Row(a=1), Row(a=2)])
def test_select_explain_result(self):
select = Select()
select._result_dict = create_hits()
select.explain_result()
print(select)
print(repr(select))
self.assertIsNotNone(select.result)
self.assertEqual(len(select), 3)
def test_getitem(self):
df = create_df_from_es()
self.assertTrue(isinstance(df['a'], Column))
self.assertTrue(isinstance(df['b'], Column))
expr = df['a'] > 2
self.assertTrue(isinstance(expr, BooleanFilter))
self.assertTrue(isinstance(df[expr], DataFrame))
self.assertEqual(df[expr]._filter.build(), {'range': {'a': {'gt': 2}}})
def test_agg_date_histogram(self):
agg = Agg()
agg._result_dict = {
'took': 3,
'aggregations': {
'my_date_histogram': {
'buckets': [
{
'doc_count': 1,
'key': 1480392360000,
'key_as_string': '2016-11-29T04:06:00.000Z',
'f1': {'value': 0.1},
},
{
'doc_count': 1,
'key': 1480392420000,
'key_as_string': '2016-11-29T04:07:00.000Z',
'f1': {'value': 0.2},
def test_agg_buckets(self):
agg = Agg()
agg._result_dict = {
'took': 1,
'aggregations': {
'agg_key': {
'buckets': [
{
'key': 'a',
'f1': {'value': 100},
'f2': {'value': 1},
"doc_count": 12
},
{
'key': 'b',
'f1': {'value': 200},
'f2': {'value': 2},
"doc_count": 13
def test_agg_nested_buckets(self):
agg = Agg()
agg._result_dict = {
'aggregations': {
'agg_key1': {
'buckets': [
{
'key': 'a',
'agg_key2': {
'buckets': [
{
'key': 'x',
'f1': {'value': 100},
'f2': {'value': 1},
"doc_count": 934422
},
{
'key': 'y',
def test_agg_buckets(self):
agg = Agg()
agg._result_dict = {
'aggregations': {
'agg_key': {
'buckets': [
{
'key': 'a',
'f1': {'value': 100},
'f2': {'value': 1},
"doc_count": 934422
},
{
'key': 'b',
'f1': {'value': 200},
'f2': {'value': 2},
"doc_count": 934422
},
def test_agg_nested_buckets(self):
agg = Agg()
agg._result_dict = {
'took': 1,
'aggregations': {
'agg_key1': {
'buckets': [
{
'key': 'a',
'agg_key2': {
'buckets': [
{
'key': 'x',
'f1': {'value': 100},
'f2': {'value': 1},
"doc_count": 11
},
{