Skip to content

Commit

Permalink
Test sorted_groupby for reverse log flag
Browse files Browse the repository at this point in the history
  • Loading branch information
joelostblom committed May 16, 2020
1 parent 9089aa1 commit b4d99a1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import os
import datetime
import operator

try:
from StringIO import StringIO
Expand All @@ -32,6 +33,7 @@
get_start_time_for_period,
make_json_writer,
safe_save,
sorted_groupby,
parse_tags,
PY2,
json_arrow_encoder,
Expand Down Expand Up @@ -270,6 +272,32 @@ def test_build_csv_multiple_cols():
assert build_csv(data) == result


# sorted_groupby

def test_sorted_groupby(watson):
end = arrow.utcnow()
watson.add('foo', end.shift(hours=-25), end.shift(hours=-24), ['A'])
watson.add('bar', end.shift(hours=-1), end, ['A'])

result = list(sorted_groupby(
watson.frames,
operator.attrgetter('day'),
reverse=False))
assert result[0][0] < result[1][0]


def test_sorted_groupby_reverse(watson):
end = arrow.utcnow()
watson.add('foo', end.shift(hours=-25), end.shift(hours=-24), ['A'])
watson.add('bar', end.shift(hours=-1), end, ['A'])

result = list(sorted_groupby(
watson.frames,
operator.attrgetter('day'),
reverse=True))
assert result[0][0] > result[1][0]


# frames_to_csv

def test_frames_to_csv_empty_data(watson):
Expand Down

0 comments on commit b4d99a1

Please sign in to comment.