Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Update tests for new group_by flattening scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrco committed Oct 28, 2014
1 parent 645edb1 commit 948a0b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
8 changes: 3 additions & 5 deletions tests/core/test_build_data_with_flatten.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime
import json
from nose.tools import assert_equal
from nose.tools import assert_true
import pytz

from backdrop.core.data_set import build_data
Expand All @@ -22,8 +22,7 @@ def test_build_data_with_flatten(self):

with json_fixture('build_data_results_to_flatten.json', parse_dates=True) as result:
flat_data = build_data(result, query)
assert_equal(
flat_data.data()[:10],
assert_true(all(item in flat_data.data() for item in
(
{
'_count': 3.0,
Expand Down Expand Up @@ -105,5 +104,4 @@ def test_build_data_with_flatten(self):
'deviceCategory': 'desktop',
'pageviews:sum': 623.0,
}
)
)
)))
2 changes: 1 addition & 1 deletion tests/core/test_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def test_flattened_month_and_group_query_with_start_and_end_at(self):
start_at=d(2013, 1, 1),
end_at=d(2013, 4, 2),
flatten=True))
assert_that(data, has_length(4))
assert_that(data, has_length(8))

assert_that(data, has_item(has_entries({
'_count': 1,
Expand Down
15 changes: 7 additions & 8 deletions tests/core/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import pytz
import datetime

from backdrop.core.response import PeriodFlatData
from backdrop.core.timeseries import timeseries_the_return_of_the_keys, MONTH

from itertools import groupby
from backdrop.core.timeseries import fill_group_by_permutations, MONTH


class TestPeriodFlatData(TestCase):
Expand Down Expand Up @@ -45,11 +42,12 @@ def test_include_all_key_permutations(self):
}
]

series = timeseries_the_return_of_the_keys(start=datetime.datetime(2013, 1, 1, 0, 0, tzinfo=pytz.UTC),
series = fill_group_by_permutations(start=datetime.datetime(2013, 1, 1, 0, 0, tzinfo=pytz.UTC),
end=datetime.datetime(2013, 2, 1, 0, 0, tzinfo=pytz.UTC),
period=MONTH,
data=data,
default={"_count": 0})
default={"_count": 0},
group_by=['paymentStatus', 'paymentThing', 'no',])

assert_that(series, has_length(18))

Expand Down Expand Up @@ -81,11 +79,12 @@ def test_multiple_group_by_months(self):
},
]

series = timeseries_the_return_of_the_keys(start=datetime.datetime(2013, 1, 1, 0, 0, tzinfo=pytz.UTC),
series = fill_group_by_permutations(start=datetime.datetime(2013, 1, 1, 0, 0, tzinfo=pytz.UTC),
end=datetime.datetime(2013, 3, 1, 0, 0, tzinfo=pytz.UTC),
period=MONTH,
data=data,
default={"_count": 0})
default={"_count": 0},
group_by=['paymentStatus', 'paymentThing', 'no',])

assert_that(series, has_length(16))

Expand Down

0 comments on commit 948a0b0

Please sign in to comment.