Skip to content
Snippets Groups Projects
Commit 2e137074 authored by Daniel Palomar's avatar Daniel Palomar
Browse files

Allow to search products available for product_code

parent 80979405
No related branches found
No related tags found
1 merge request!30Allow to search products available for product_code
......@@ -23,11 +23,11 @@ class ProductCatalog:
self.products = [Product(**product) for product in products]
@classmethod
def search(cls, code="", category="", lang="ca"):
def search(cls, code="", category="", lang="ca", product_code=""):
headers = {'Accept-Language': lang}
response_data = Client().get(
"{}".format(cls._url_path),
params={"code": code, "categ": category},
params={"code": code, "categ": category, "product_code": product_code},
extra_headers=headers
)
......
interactions:
- request:
body: null
headers:
API-KEY:
- '****'
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Accept-Language:
- ca
Connection:
- keep-alive
User-Agent:
- python-requests/2.27.1
method: GET
uri: http://odoo-sc.local:8069/api/product-catalog?code=&categ=&product_code=SE_SC_REC_BA_F_100
response:
body:
string: '{"pricelists": [{"code": "21IVA", "products": [
{"code": "SE_SC_REC_BA_F_100", "name": "Fibra 100Mb amb fix", "price": 34.0,
"category": "fiber", "minutes": null, "data": null, "bandwidth": 100, "available_for":
["member"]}, {"code": "SE_SC_REC_BA_F_1024", "name": "Fibra 1Gb", "price":
58.0, "category": "fiber", "minutes": null, "data": null, "bandwidth": 1000,
"available_for": ["member"]}, {"code": "SE_SC_REC_BA_F_600", "name": "Fibra
600Mb", "price": 43.0, "category": "fiber", "minutes": null, "data": null,
"bandwidth": 600, "available_for": ["member"]}]}]}'
headers:
Access-Control-Allow-Methods:
- GET
Access-Control-Allow-Origin:
- None
Content-Length:
- '2873'
Content-Type:
- application/json
Cookie: '****'
Date:
- Tue, 8 Apr 2022 11:25:49 GMT
Server:
- Werkzeug/0.11.15 Python/3.7.7
Set-Cookie: '****'
status:
code: 200
message: OK
version: 1
......@@ -75,3 +75,22 @@ class TariffTests(unittest.TestCase):
"Ilimitadas 10 GB",
es_product_names
)
@pytest.mark.vcr()
def test_search_available_products_for_product_code(self):
""" For product fibra 100Mb only are available other Fiber products. """
pricelists = ProductCatalog.search(product_code="SE_SC_REC_BA_F_100")
product_codes = [p.code for p in pricelists[0].products]
self.assertIn(
"SE_SC_REC_BA_F_1024",
product_codes
)
self.assertIn(
"SE_SC_REC_BA_F_600",
product_codes
)
self.assertNotIn(
"SE_SC_REC_BA_ADSL_SF",
product_codes
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment