Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • coopdevs/som-connexio/odoo/odoo-somconnexio-python-client
1 result
Show changes
Commits on Source (10)
......@@ -6,12 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.1.36] - 2023-06-07
## [0.1.37] - 2023-07-27
### Added
* Attribut mobiles_sharing_data in FiberContractsToPack. [#70](https://git.coopdevs.org/coopdevs/som-connexio/odoo-somconnexio-python-client/-/merge_requests/70)
* OneShot and OneShot Catalog as resources. [#73](https://git.coopdevs.org/coopdevs/som-connexio/odoo-somconnexio-python-client/-/merge_requests/73)
## [0.1.36] - 2023-06-01
## [0.1.36] - 2023-06-07
### Added
* Attribut mobiles_sharing_data in FiberContractsToPack. [#70](https://git.coopdevs.org/coopdevs/som-connexio/odoo-somconnexio-python-client/-/merge_requests/70)
* Attributes in contract Contract model. [#68](https://git.coopdevs.org/coopdevs/som-connexio/odoo-somconnexio-python-client/-/merge_requests/68)
## [0.1.35] - 2023-05-29
......
__version__ = "0.1.36"
__version__ = "0.1.37"
from odoo_somconnexio_python_client.client import Client
class OneShot:
def __init__(self, name, code, price, minutes="", data="", **kwargs):
self.code = code
self.name = name
self.price = price
self.minutes = minutes
self.data = data
class OneShotCatalog:
_url_path = "/one-shot-catalog"
def __init__(self, code, one_shots, **kwargs):
self.code = code
self.one_shots = [OneShot(**product) for product in one_shots]
@classmethod
def search(cls, code="21IVA", product_code="", lang="ca"):
headers = {"Accept-Language": lang}
response_data = Client().get(
cls._url_path,
params={"code": code, "product_code": product_code},
extra_headers=headers,
)
pricelists = []
for pricelist in response_data.get("pricelists"):
pricelists.append(cls(**pricelist))
return pricelists
......@@ -75,7 +75,7 @@ class ProductCatalog:
def search(cls, code="", category="", lang="ca", product_code=""):
headers = {"Accept-Language": lang}
response_data = Client().get(
"{}".format(cls._url_path),
cls._url_path,
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/one-shot-catalog?code=21IVA&product_code=SE_SC_REC_MOBILE_T_150_1024
response:
body:
string: '{"pricelists": [{"code": "21IVA", "one_shots": [{"code": "CH_SC_OSO_1GB_ADDICIONAL",
"name": "1 GB Addicionals", "price": 1.0, "minutes": 0, "data": 1024}, {"code":
"CH_SC_OSO_3GB_ADDICIONAL", "name": "3 GB Addicionals", "price": 1.0, "minutes":
0, "data": 3072}, {"code": "CH_SC_OSO_500MB_ADDICIONAL", "name": "500 MB Addicionals",
"price": 1.0, "minutes": 0, "data": 500}]}]}'
headers:
Access-Control-Allow-Methods:
- GET
Access-Control-Allow-Origin:
- None
Content-Length:
- '377'
Content-Type:
- application/json
Cookie: '****'
Date:
- Wed, 12 Jul 2023 06:47:13 GMT
Server:
- Werkzeug/0.11.15 Python/3.7.7
Set-Cookie: '****'
status:
code: 200
message: OK
version: 1
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/one-shot-catalog?code=21IVA&product_code=BBBB
response:
body:
string: '{"pricelists": [{"code": "21IVA", "one_shots": []}]}'
headers:
Access-Control-Allow-Methods:
- GET
Access-Control-Allow-Origin:
- None
Content-Length:
- '52'
Content-Type:
- application/json
Cookie: '****'
Date:
- Wed, 12 Jul 2023 06:47:13 GMT
Server:
- Werkzeug/0.11.15 Python/3.7.7
Set-Cookie: '****'
status:
code: 200
message: OK
version: 1
......@@ -15,14 +15,6 @@ from odoo_somconnexio_python_client.resources.contract import (
)
@pytest.fixture(scope="module")
def vcr_config():
return {
# Replace the API-KEY request header with "DUMMY" in cassettes
"filter_headers": [("API-KEY", "DUMMY")],
}
class ContractTests(unittest.TestCase):
@pytest.mark.vcr()
def test_search_resource_not_found(self):
......@@ -103,7 +95,6 @@ class ContractTests(unittest.TestCase):
assert paging.sortBy == "code"
assert paging.sortOrder == "DESCENDENT"
@pytest.mark.vcr()
def test_search_contract_by_customer_ref_with_pagination_bad_limit(self):
self.assertRaises(
NotNumericLimit,
......@@ -112,7 +103,6 @@ class ContractTests(unittest.TestCase):
limit="XXX",
)
@pytest.mark.vcr()
def test_search_contract_by_customer_ref_with_pagination_bad_offset(self):
self.assertRaises(
NotNumericOffset,
......@@ -122,7 +112,6 @@ class ContractTests(unittest.TestCase):
offset="XXX",
)
@pytest.mark.vcr()
def test_search_contract_by_customer_ref_with_pagination_bad_sort_order(self):
self.assertRaises(
InvalidSortOrder,
......
from __future__ import unicode_literals # support both Python2 and 3
import pytest
import unittest2 as unittest
from odoo_somconnexio_python_client.resources.one_shot_catalog import (
OneShot,
OneShotCatalog,
)
class OneShotTariffTests(unittest.TestCase):
@pytest.mark.vcr()
def test_search_code(self):
pricelists = OneShotCatalog.search(
code="21IVA", product_code="SE_SC_REC_MOBILE_T_150_1024"
)
tariff_names = []
tariff_codes = []
pricelist_21IVA = pricelists[0]
self.assertIsInstance(pricelist_21IVA, OneShotCatalog)
self.assertEqual(pricelist_21IVA.code, "21IVA")
for one_shot in pricelist_21IVA.one_shots:
self.assertIsInstance(one_shot, OneShot)
tariff_names.append(one_shot.name)
tariff_codes.append(one_shot.code)
self.assertIn("1 GB Addicionals", tariff_names)
self.assertIn("CH_SC_OSO_1GB_ADDICIONAL", tariff_codes)
@pytest.mark.vcr()
def test_search_non_existant_product_code(self):
pricelists = OneShotCatalog.search(product_code="BBBB")
self.assertEqual(len(pricelists[0].one_shots), 0)