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

Commit

Permalink
wip - expectations for enforcing latest period
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbashdown committed Jul 20, 2015
1 parent 11d6c85 commit 0b5a956
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
[
{
"_day_start_at": "2012-01-01T00:00:00+00:00",
"_hour_start_at": "2012-01-01T00:00:00+00:00",
"_id": "MjAxMi0wMS0wMSAwMDowMDowMDIwMTMtMDEtMDEgMDA6MDA6MDBiaXMtYW5udWFsLXJldHVybnM=",
"_month_start_at": "2012-01-01T00:00:00+00:00",
"_quarter_start_at": "2012-01-01T00:00:00+00:00",
"_timestamp": "2014-01-01T00:00:00+00:00",
"_updated_at": "2014-03-19T10:44:32.287000+00:00",
"_week_start_at": "2013-12-26T00:00:00+00:00",
"cost_per_transaction": null,
"digital_cost_per_transaction": 2.36,
"digital_takeup": null,
"end_at": "2013-01-01T00:00:00+00:00",
"number_of_digital_transactions": 2301214,
"number_of_transactions": 2358738,
"period": "year",
"service_id": "service-with-quarterly-not-latest",
"total_cost": null,
"type": "quarterly"
},
{
"_day_start_at": "2012-01-01T00:00:00+00:00",
"_hour_start_at": "2012-01-01T00:00:00+00:00",
Expand Down Expand Up @@ -124,7 +144,7 @@
"_id": "MjAxMS0wNC0wMSAwMDowMDowMDIwMTItMDQtMDEgMDA6MDA6MDBiaXMtYW5udWFsLXJldHVybnM=",
"_month_start_at": "2013-04-01T00:00:00+00:00",
"_quarter_start_at": "2013-04-01T00:00:00+00:00",
"_timestamp": "2013-04-01T00:00:00+00:00",
"_timestamp": "2013-01-01T00:00:00+00:00",
"_updated_at": "2014-03-19T10:44:32.286000+00:00",
"_week_start_at": "2013-03-28T00:00:00+00:00",
"cost_per_transaction": 5.2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
data = json.loads(f.read())

data_to_post = [
{
"_id": encode_id('quart', 'digital_cost_per_transaction'),
"_timestamp": "2014-12-12T00:00:00+00:00",
"digital_cost_per_transaction": None,
"end_at": "2013-01-01T00:00:00+00:00",
"period": "year",
"service_id": "service-with-quarterly-not-latest",
"dashboard_slug": "quart",
"type": "quarterly"
},
{
'_timestamp': u'2014-12-12T00:00:00+00:00',
"_id": encode_id('quart', 'digital_takeup'),
'period': u'year',
'end_at': u'2013-01-01T00:00:00+00:00',
'dashboard_slug': 'quart',
'service_id': u'service-with-quarterly-not-latest',
'digital_takeup': None,
"type": "quarterly"
},
{
"_id": encode_id('quarterly-nonsense', 'digital_cost_per_transaction'),
"_timestamp": "2014-12-12T00:00:00+00:00",
Expand Down Expand Up @@ -67,7 +87,7 @@
{
"_id": encode_id('sorn', 'cost_per_transaction'),
"_timestamp": "2013-04-01T00:00:00+00:00",
"cost_per_transaction": 5.2,
"cost_per_transaction": None,
"end_at": "2012-04-01T00:00:00+00:00",
"period": "year",
"service_id": "sorn-innit",
Expand All @@ -77,7 +97,7 @@
{
"_id": encode_id('sorn', 'digital_cost_per_transaction'),
"_timestamp": "2013-04-01T00:00:00+00:00",
"digital_cost_per_transaction": 2.52,
"digital_cost_per_transaction": None,
"end_at": "2012-04-01T00:00:00+00:00",
"period": "year",
"service_id": "sorn-innit",
Expand All @@ -91,7 +111,7 @@
# the data_type is digital_takeup.
"_id": encode_id('sorn', 'digital_takeup'),
"_timestamp": "2013-04-01T00:00:00+00:00",
"digital_takeup": 0.965537995968002,
"digital_takeup": None,
"end_at": "2012-04-01T00:00:00+00:00",
"period": "year",
"service_id": "sorn-innit",
Expand All @@ -102,7 +122,7 @@
"_id": encode_id('sorn', 'number_of_digital_transactions'),
"_timestamp": "2013-04-01T00:00:00+00:00",
"end_at": "2012-04-01T00:00:00+00:00",
"number_of_digital_transactions": 2184914,
"number_of_digital_transactions": None,
"period": "year",
"service_id": "sorn-innit",
"dashboard_slug": "sorn",
Expand All @@ -115,7 +135,7 @@
"period": "year",
"service_id": "sorn-innit",
"dashboard_slug": "sorn",
"total_cost": 11767069.6,
"total_cost": None,
"type": "seasonally-adjusted"
},
{
Expand Down Expand Up @@ -206,6 +226,11 @@
'slug': 'quarterly-nonsense2'
}
]
quarterly_data_not_latest = [
{
'slug': 'quart'
}
]


class ComputeTestCase(unittest.TestCase):
Expand All @@ -228,7 +253,8 @@ def test_compute(self, mock_dashboard_finder, mock_dataset):
mock_dashboard_finder.side_effect = lambda x: {
'bis-annual-returns': bis_returns_dashboard_config,
'sorn-innit': sorn_dashboard_config,
'service-with-quarterly-data': quarterly_data_dashboard_config
'service-with-quarterly-data': quarterly_data_dashboard_config,
'service-with-quarterly-not-latest': quarterly_data_not_latest,
}.get(x, [])
transformed_data = compute(data, {'output': {
'data-group': 'transactions-explorer',
Expand Down Expand Up @@ -258,7 +284,8 @@ def test_compute_when_no_new_data(
mock_dashboard_finder.side_effect = lambda x: {
'bis-annual-returns': bis_returns_dashboard_config,
'sorn-innit': sorn_dashboard_config,
'service-with-quarterly-data': quarterly_data_dashboard_config
'service-with-quarterly-data': quarterly_data_dashboard_config,
'service-with-quarterly-not-latest': quarterly_data_not_latest,
}.get(x, [])
transformed_data = compute(data, {'output': {
'data-group': 'transactions-explorer',
Expand Down

0 comments on commit 0b5a956

Please sign in to comment.