Adds a category field in 'get_category()'

This commit is contained in:
Fred Z 2018-08-01 18:11:04 +02:00
parent 9721a62951
commit 01557cf9ae

View File

@ -34,7 +34,8 @@ def get_product(code):
e e
>>> print(prod_beurre['categories_tags']) >>> print(prod_beurre['categories_tags'])
['en:sugary-snacks', 'en:biscuits-and-cakes', 'en:biscuits', 'fr:petits-beurres'] ['en:sugary-snacks', 'en:biscuits-and-cakes', \
'en:biscuits', 'fr:petits-beurres']
>>> print(prod_oreo['code']) >>> print(prod_oreo['code'])
8410000810004 8410000810004
@ -46,7 +47,8 @@ def get_product(code):
e e
>>> print(prod_oreo['categories_tags']) >>> print(prod_oreo['categories_tags'])
['en:sugary-snacks', 'en:biscuits-and-cakes', 'en:biscuits', 'en:chocolate-biscuits', 'es:sandwich-cookies'] ['en:sugary-snacks', 'en:biscuits-and-cakes', 'en:biscuits', \
'en:chocolate-biscuits', 'es:sandwich-cookies']
>>> prod_false is False >>> prod_false is False
True True
@ -99,6 +101,9 @@ def get_category(name, from_file=False):
:Tests OFFLINE: :Tests OFFLINE:
>>> prod_bisc = get_category('biscuits', True) >>> prod_bisc = get_category('biscuits', True)
>>> prod_bisc['category'] == 'biscuits'
True
>>> 'count' in prod_bisc >>> 'count' in prod_bisc
True True
@ -142,6 +147,7 @@ def get_category(name, from_file=False):
if category_json['count'] is not 0 and status == 200: if category_json['count'] is not 0 and status == 200:
category_kept = { category_kept = {
'count': category_json['count'], 'count': category_json['count'],
'category': str(name),
'products': [] 'products': []
} }
@ -171,7 +177,8 @@ def pick_category(cat_list):
by langage prefix. by langage prefix.
:Tests: :Tests:
>>> pick_category(['en:sugary-snacks', 'en:biscuits-and-cakes', 'en:biscuits']) >>> pick_category(['en:sugary-snacks', 'en:biscuits-and-cakes', \
'en:biscuits'])
'biscuits' 'biscuits'
""" """
if len(cat_list) > 1: if len(cat_list) > 1: