From 7d3a62244d9c7077496cbd13c30f1cfc98dd69a2 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 26 Nov 2020 16:32:09 +0100 Subject: [PATCH 2/4] tests: format dataviz using black (#48865) --- tests/test_dataviz.py | 69 +++++++++++-------------------------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py index 6086f166..66a5765a 100644 --- a/tests/test_dataviz.py +++ b/tests/test_dataviz.py @@ -16,6 +16,7 @@ from .test_public import login, normal_user pytestmark = pytest.mark.django_db + @pytest.fixture def cell(): page = Page(title='One', slug='index') @@ -133,9 +134,7 @@ def bijoe_mock(url, request): response = { 'format': '1', 'data': [222, 134, 0, 53], - 'axis': { - 'x_labels': ['web', 'mail', 'phone', 'email'] - }, + 'axis': {'x_labels': ['web', 'mail', 'phone', 'email']}, 'measure': 'integer', } return {'content': json.dumps(response), 'request': request, 'status_code': 200} @@ -143,23 +142,15 @@ def bijoe_mock(url, request): response = { 'format': '1', 'data': [222, 134, 0, 53], - 'axis': { - 'y_labels': ['web', 'mail', 'phone', 'email'] - }, + 'axis': {'y_labels': ['web', 'mail', 'phone', 'email']}, 'measure': 'integer', } return {'content': json.dumps(response), 'request': request, 'status_code': 200} if url.path == '/visualization/3/json/': response = { 'format': '1', - 'data': [ - [222, 134, 0, 53], - [122, 114, 2, 33], - ], - 'axis': { - 'x_labels': ['web', 'mail', 'phone', 'email'], - 'y_labels': ['foo', 'bar'], - }, + 'data': [[222, 134, 0, 53], [122, 114, 2, 33],], + 'axis': {'x_labels': ['web', 'mail', 'phone', 'email'], 'y_labels': ['foo', 'bar'],}, 'measure': 'integer', } return {'content': json.dumps(response), 'request': request, 'status_code': 200} @@ -174,27 +165,15 @@ def bijoe_mock(url, request): if url.path == '/visualization/5/json/': response = { 'format': '1', - 'data': [ - [222, 134, 0, 53], - [122, 114, 2, 33], - ], - 'axis': { - 'x_labels': ['web', 'mail', 'phone', 'email'], - 'loop': ['foo', 'bar'], - } + 'data': [[222, 134, 0, 53], [122, 114, 2, 33],], + 'axis': {'x_labels': ['web', 'mail', 'phone', 'email'], 'loop': ['foo', 'bar'],}, } return {'content': json.dumps(response), 'request': request, 'status_code': 200} if url.path == '/visualization/6/json/': response = { 'format': '1', - 'data': [ - [222, 134, 0, 53], - [122, 114, 2, 33], - ], - 'axis': { - 'y_labels': ['web', 'mail', 'phone', 'email'], - 'loop': ['foo', 'bar'], - } + 'data': [[222, 134, 0, 53], [122, 114, 2, 33],], + 'axis': {'y_labels': ['web', 'mail', 'phone', 'email'], 'loop': ['foo', 'bar'],}, } return {'content': json.dumps(response), 'request': request, 'status_code': 200} if url.path == '/visualization/7/json/': @@ -210,16 +189,14 @@ def bijoe_mock(url, request): 'x_labels': ['foo', 'bar'], 'y_labels': ['web', 'mail', 'phone', 'email'], 'loop': ['a', 'b', 'c', 'd'], - } + }, } return {'content': json.dumps(response), 'request': request, 'status_code': 200} if url.path == '/visualization/8/json/': response = { 'format': '1', 'data': [1000, 123000, 8600, 86400], - 'axis': { - 'y_labels': ['web', 'mail', 'email', 'fax'] - }, + 'axis': {'y_labels': ['web', 'mail', 'email', 'fax']}, 'unit': 'seconds', 'measure': 'duration', } @@ -227,24 +204,15 @@ def bijoe_mock(url, request): if url.path == '/visualization/9/json/': response = { 'format': '1', - 'data': [ - [1, 1, 1, 1], - [1], - [1, 1], - ], - 'axis': { - 'y_labels': ['web', 'mail', 'email'], - 'loop': ['a', 'b', 'c', 'd'], - } + 'data': [[1, 1, 1, 1], [1], [1, 1],], + 'axis': {'y_labels': ['web', 'mail', 'email'], 'loop': ['a', 'b', 'c', 'd'],}, } return {'content': json.dumps(response), 'request': request, 'status_code': 200} if url.path == '/visualization/10/json/': response = { 'format': '1', 'data': [10, 20, 30, 40, 0], - 'axis': { - 'y_labels': ['web', 'mail', 'email', 'fax', 'phone'] - }, + 'axis': {'y_labels': ['web', 'mail', 'email', 'fax', 'phone']}, 'unit': None, 'measure': 'percent', } @@ -256,7 +224,6 @@ def bijoe_mock(url, request): return {'content': json.dumps(response), 'request': request, 'status_code': 404} - @with_httmock(bijoe_mock) def test_chartng_cell(app): page = Page(title='One', slug='index') @@ -288,7 +255,7 @@ def test_chartng_cell(app): assert chart.raw_series == [ ([222], {'title': u'web'}), ([134], {'title': u'mail'}), - ([53], {'title': u'email'}) + ([53], {'title': u'email'}), ] # data in Y @@ -400,7 +367,7 @@ def test_chartng_cell_hide_null_values(app): assert chart.raw_series == [ ([222], {'title': u'web'}), ([134], {'title': u'mail'}), - ([53], {'title': u'email'}) + ([53], {'title': u'email'}), ] # data in Y @@ -489,7 +456,7 @@ def test_chartng_cell_sort_order_alpha(app): assert chart.raw_series == [ ([53], {'title': u'email'}), ([134], {'title': u'mail'}), - ([222], {'title': u'web'}) + ([222], {'title': u'web'}), ] # data in Y @@ -578,7 +545,7 @@ def test_chartng_cell_sort_order_desc(app): assert chart.raw_series == [ ([222], {'title': u'web'}), ([134], {'title': u'mail'}), - ([53], {'title': u'email'}) + ([53], {'title': u'email'}), ] # data in Y -- 2.20.1