def test_all_terms(self): series_input = [ { "options": {"source": SalesHistory.objects.all()}, "terms": [ "price", { "genre": { "field": "book__genre__name", "source": SalesHistory.objects.filter(price__gte=10), "field_alias": "gnr", } }, ], } ] series_cleaned = { "price": {"source": SalesHistory.objects.all(), "field": "price", "field_alias": "price"}, "genre": { "source": SalesHistory.objects.filter(price__gte=10), "field": "book__genre__name", "field_alias": "gnr", }, } self.assertOptionDictsEqual(clean_dps(series_input), series_cleaned)
def test_terms_list_all_str(self): series_input = [{"options": {"source": SalesHistory.objects.all()}, "terms": ["price", "book__genre__name"]}] series_cleaned = { "price": {"source": SalesHistory.objects.all(), "field": "price", "field_alias": "price"}, "book__genre__name": { "source": SalesHistory.objects.all(), "field": "book__genre__name", "field_alias": "name", }, } self.assertOptionDictsEqual(clean_dps(series_input), series_cleaned)
def test_terms_is_a_dict(self): series_input = \ [{'options': {'source': SalesHistory.objects.all()}, 'terms': {'price': {}} }] series_cleaned = \ {'price': { 'source': SalesHistory.objects.all(), 'field': 'price', 'field_alias': 'price'}} self.assertOptionDictsEqual(clean_dps(series_input), series_cleaned)
def test_terms_list_all_str(self): series_input = \ [{'options': {'source': SalesHistory.objects.all()}, 'terms': [ 'price', 'book__genre__name'] }] series_cleaned = \ {'price': { 'source': SalesHistory.objects.all(), 'field': 'price', 'field_alias': 'price'}, 'book__genre__name':{ 'source': SalesHistory.objects.all(), 'field': 'book__genre__name', 'field_alias': 'name'}} self.assertOptionDictsEqual(clean_dps(series_input), series_cleaned)
def test_all_terms(self): series_input = \ [{'options': {'source': SalesHistory.objects.all()}, 'terms': [ 'price', {'genre': { 'field': 'book__genre__name', 'source': SalesHistory.objects.filter(price__gte=10), 'field_alias': 'gnr'}}] }] series_cleaned = \ {'price': { 'source': SalesHistory.objects.all(), 'field': 'price', 'field_alias': 'price'}, 'genre':{ 'source': SalesHistory.objects.filter(price__gte=10), 'field': 'book__genre__name', 'field_alias': 'gnr'}} self.assertOptionDictsEqual(clean_dps(series_input), series_cleaned)
def test_terms_is_a_dict(self): series_input = [{"options": {"source": SalesHistory.objects.all()}, "terms": {"price": {}}}] series_cleaned = {"price": {"source": SalesHistory.objects.all(), "field": "price", "field_alias": "price"}} self.assertOptionDictsEqual(clean_dps(series_input), series_cleaned)