odoo-somconnexio-python-client 0.2.1__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/PKG-INFO +1 -1
- odoo_somconnexio_python_client-0.2.3/odoo_somconnexio_python_client/__init__.py +1 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/crm_lead.py +27 -0
- odoo_somconnexio_python_client-0.2.3/odoo_somconnexio_python_client/resources/documents.py +14 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/partner.py +25 -1
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client.egg-info/PKG-INFO +1 -1
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client.egg-info/SOURCES.txt +2 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_crm_lead.py +34 -1
- odoo_somconnexio_python_client-0.2.3/tests/resources/test_documents.py +22 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_partner.py +30 -0
- odoo_somconnexio_python_client-0.2.1/odoo_somconnexio_python_client/__init__.py +0 -1
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/LICENSE +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/README.md +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/client.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/exceptions.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/helpers.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/__init__.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/address.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/broadband_isp_info.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/contract.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/coop_agreement.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/crm_lead_line.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/discovery_channel.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/fiber_contracts.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/invoice.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/knowledge.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/mobile_isp_info.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/mobile_offer_catalog.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/multimedia_contract.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/odoo_paging.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/one_shot_catalog.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/product_catalog.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/project_task.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/provider.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/sponsees.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client/resources/subscription_request.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client.egg-info/dependency_links.txt +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client.egg-info/not-zip-safe +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client.egg-info/requires.txt +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/odoo_somconnexio_python_client.egg-info/top_level.txt +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/setup.cfg +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/setup.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/__init__.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_address.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_contract.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_coop_agreement.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_discovery_channel.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_fiber_contracts.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_invoice.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_knowledge.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_mobile_offer_catalog.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_multimedia_contract.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_one_shot_catalog.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_product_catalog.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_project_task.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_providers.py +0 -0
- {odoo_somconnexio_python_client-0.2.1 → odoo_somconnexio_python_client-0.2.3}/tests/resources/test_subscription_request.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.3"
|
|
@@ -37,3 +37,30 @@ class CRMLead:
|
|
|
37
37
|
response_data = Client().post("{}/create".format(cls._url_path), kwargs)
|
|
38
38
|
|
|
39
39
|
return cls(**response_data)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class CRMLeadDocument(CRMLead):
|
|
43
|
+
def __init__(
|
|
44
|
+
self, crm_lead_id, crm_lead_token, document_category, document_id, document_exit
|
|
45
|
+
):
|
|
46
|
+
self.crm_lead_id = crm_lead_id
|
|
47
|
+
self.crm_lead_token = crm_lead_token
|
|
48
|
+
self.document_category = document_category
|
|
49
|
+
self.document_id = document_id
|
|
50
|
+
self.document_exit = document_exit
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def get_required_docs_by_token(cls, crm_lead_token):
|
|
54
|
+
return cls._get_get_required_docs(params={"crm_lead_token": crm_lead_token})
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def get_required_docs_by_id(cls, lead_id):
|
|
58
|
+
return cls._get_get_required_docs(params={"lead_id": lead_id})
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def _get_get_required_docs(cls, params={}):
|
|
62
|
+
url_path = "{}/{}".format(cls._url_path, "documents-required")
|
|
63
|
+
response_data = Client().get(url_path, params=params, secondary_domain=True)
|
|
64
|
+
if not response_data:
|
|
65
|
+
return []
|
|
66
|
+
return [cls(**data) for data in response_data]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from odoo_somconnexio_python_client.client import Client
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Documents:
|
|
5
|
+
_url_path = "/documentation"
|
|
6
|
+
|
|
7
|
+
@classmethod
|
|
8
|
+
def send_docs(cls, crm_lead_id, category, files):
|
|
9
|
+
body = {"crm_lead_id": crm_lead_id, "category": category, "files": files}
|
|
10
|
+
return Client().post(
|
|
11
|
+
cls._url_path,
|
|
12
|
+
body,
|
|
13
|
+
secondary_domain=True,
|
|
14
|
+
)
|
|
@@ -82,11 +82,12 @@ class Partner:
|
|
|
82
82
|
def check_sponsor(cls, vat, sponsor_code):
|
|
83
83
|
"""
|
|
84
84
|
Check if partner can sponsor new partners.
|
|
85
|
+
Check a sponsorship code against the VAT number
|
|
85
86
|
|
|
86
87
|
:return: True or False
|
|
87
88
|
"""
|
|
88
89
|
if not vat or not sponsor_code:
|
|
89
|
-
return False
|
|
90
|
+
return False, "sponsor_code and vat number are required"
|
|
90
91
|
|
|
91
92
|
url = "{}/{}".format(cls._url_path, "check_sponsor")
|
|
92
93
|
params = {
|
|
@@ -101,6 +102,29 @@ class Partner:
|
|
|
101
102
|
raise ResourceNotFound(resource=cls.__name__, filter=params)
|
|
102
103
|
return response_data["result"] == "allowed", response_data["message"]
|
|
103
104
|
|
|
105
|
+
@classmethod
|
|
106
|
+
def check_sponsor_code(cls, sponsor_code):
|
|
107
|
+
"""
|
|
108
|
+
Check if partner can sponsor new partners.
|
|
109
|
+
Check a sponsorship code
|
|
110
|
+
|
|
111
|
+
:return: True or False
|
|
112
|
+
"""
|
|
113
|
+
if not sponsor_code:
|
|
114
|
+
return False, "sponsor_code is required"
|
|
115
|
+
|
|
116
|
+
url = "{}/{}".format(cls._url_path, "check_sponsor_code")
|
|
117
|
+
params = {
|
|
118
|
+
"sponsor_code": sponsor_code,
|
|
119
|
+
}
|
|
120
|
+
response_data = Client().get(
|
|
121
|
+
url,
|
|
122
|
+
params=params,
|
|
123
|
+
)
|
|
124
|
+
if not response_data:
|
|
125
|
+
raise ResourceNotFound(resource=cls.__name__, filter=params)
|
|
126
|
+
return response_data["result"] == "allowed", response_data["message"]
|
|
127
|
+
|
|
104
128
|
@classmethod
|
|
105
129
|
def sponsees(cls, ref):
|
|
106
130
|
"""
|
|
@@ -19,6 +19,7 @@ odoo_somconnexio_python_client/resources/coop_agreement.py
|
|
|
19
19
|
odoo_somconnexio_python_client/resources/crm_lead.py
|
|
20
20
|
odoo_somconnexio_python_client/resources/crm_lead_line.py
|
|
21
21
|
odoo_somconnexio_python_client/resources/discovery_channel.py
|
|
22
|
+
odoo_somconnexio_python_client/resources/documents.py
|
|
22
23
|
odoo_somconnexio_python_client/resources/fiber_contracts.py
|
|
23
24
|
odoo_somconnexio_python_client/resources/invoice.py
|
|
24
25
|
odoo_somconnexio_python_client/resources/knowledge.py
|
|
@@ -39,6 +40,7 @@ tests/resources/test_contract.py
|
|
|
39
40
|
tests/resources/test_coop_agreement.py
|
|
40
41
|
tests/resources/test_crm_lead.py
|
|
41
42
|
tests/resources/test_discovery_channel.py
|
|
43
|
+
tests/resources/test_documents.py
|
|
42
44
|
tests/resources/test_fiber_contracts.py
|
|
43
45
|
tests/resources/test_invoice.py
|
|
44
46
|
tests/resources/test_knowledge.py
|
|
@@ -2,10 +2,11 @@ from __future__ import unicode_literals # support both Python2 and 3
|
|
|
2
2
|
|
|
3
3
|
from mock import patch
|
|
4
4
|
|
|
5
|
+
import pytest
|
|
5
6
|
import unittest2 as unittest
|
|
6
7
|
|
|
7
8
|
from ..settings import REQUIRED_ENVVARS
|
|
8
|
-
from odoo_somconnexio_python_client.resources.crm_lead import CRMLead
|
|
9
|
+
from odoo_somconnexio_python_client.resources.crm_lead import CRMLead, CRMLeadDocument
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
@patch("odoo_somconnexio_python_client.resources.crm_lead.Client.post")
|
|
@@ -107,3 +108,35 @@ class CRMLeadTests(unittest.TestCase):
|
|
|
107
108
|
|
|
108
109
|
for key, value in broadband_isp_info_data.items():
|
|
109
110
|
self.assertEqual(getattr(broadband_isp_info, key), value)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class CRMLeadDocumentTest(unittest.TestCase):
|
|
114
|
+
def setUp(self):
|
|
115
|
+
self.id = 63
|
|
116
|
+
self.token = "JjoHC8jmL7tvNu7Bh2k2Sz1H2o3J1ciwirjGHYz6OlM"
|
|
117
|
+
|
|
118
|
+
@pytest.mark.vcr()
|
|
119
|
+
def test_get_required_docs_by_token(self):
|
|
120
|
+
docs = CRMLeadDocument.get_required_docs_by_token(self.token)
|
|
121
|
+
self._assert_successful_response(docs)
|
|
122
|
+
|
|
123
|
+
@pytest.mark.vcr()
|
|
124
|
+
def test_get_required_docs_by_token_not_found(self):
|
|
125
|
+
docs = CRMLeadDocument.get_required_docs_by_token("token")
|
|
126
|
+
self.assertFalse(len(docs))
|
|
127
|
+
|
|
128
|
+
@pytest.mark.vcr()
|
|
129
|
+
def test_get_required_docs_by_id(self):
|
|
130
|
+
docs = CRMLeadDocument.get_required_docs_by_id(self.id)
|
|
131
|
+
self._assert_successful_response(docs)
|
|
132
|
+
|
|
133
|
+
@pytest.mark.vcr()
|
|
134
|
+
def test_get_required_docs_by_id_not_found(self):
|
|
135
|
+
docs = CRMLeadDocument.get_required_docs_by_id(999999)
|
|
136
|
+
self.assertFalse(len(docs))
|
|
137
|
+
|
|
138
|
+
def _assert_successful_response(self, docs):
|
|
139
|
+
assert docs[0].crm_lead_id == self.id
|
|
140
|
+
assert docs[0].crm_lead_token == self.token
|
|
141
|
+
assert docs[0].document_category == "dni_titular_actual"
|
|
142
|
+
self.assertTrue(docs[0].document_exit)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from mock import patch
|
|
2
|
+
|
|
3
|
+
from odoo_somconnexio_python_client.resources.documents import Documents
|
|
4
|
+
import unittest2 as unittest
|
|
5
|
+
|
|
6
|
+
from ..settings import REQUIRED_ENVVARS
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@patch("odoo_somconnexio_python_client.resources.crm_lead.Client.post")
|
|
10
|
+
@patch.dict("os.environ", REQUIRED_ENVVARS)
|
|
11
|
+
class DocumentsTests(unittest.TestCase):
|
|
12
|
+
def test_send_docs(self, client_post_mock):
|
|
13
|
+
crm_lead_id = 1
|
|
14
|
+
category = "dnianterior"
|
|
15
|
+
files = ["file1", "file2"]
|
|
16
|
+
result = Documents.send_docs(crm_lead_id, category, files)
|
|
17
|
+
assert result == client_post_mock.return_value
|
|
18
|
+
client_post_mock.assert_called_with(
|
|
19
|
+
"/documentation",
|
|
20
|
+
{"crm_lead_id": crm_lead_id, "category": category, "files": files},
|
|
21
|
+
secondary_domain=True,
|
|
22
|
+
)
|
|
@@ -35,6 +35,16 @@ class PartnerTests(unittest.TestCase):
|
|
|
35
35
|
assert "new_service" in partner.banned_actions
|
|
36
36
|
self.assertFalse(partner.is_company)
|
|
37
37
|
|
|
38
|
+
def test_check_sponsor_ko_sponsor_code_not_informed(self):
|
|
39
|
+
result, message = Partner.check_sponsor("ES12345678X", "")
|
|
40
|
+
assert not result
|
|
41
|
+
assert message == "sponsor_code and vat number are required"
|
|
42
|
+
|
|
43
|
+
def test_check_sponsor_ko_vat_not_informed(self):
|
|
44
|
+
result, message = Partner.check_sponsor("", "XXXXX")
|
|
45
|
+
assert not result
|
|
46
|
+
assert message == "sponsor_code and vat number are required"
|
|
47
|
+
|
|
38
48
|
@pytest.mark.vcr()
|
|
39
49
|
def test_check_sponsor_ok(self):
|
|
40
50
|
sponsor_code = "cac3c"
|
|
@@ -62,6 +72,26 @@ class PartnerTests(unittest.TestCase):
|
|
|
62
72
|
assert not result
|
|
63
73
|
assert message == "invalid code or vat number"
|
|
64
74
|
|
|
75
|
+
def test_check_sponsor_code_ko_code_not_informed(self):
|
|
76
|
+
sponsor_code = ""
|
|
77
|
+
result, message = Partner.check_sponsor_code(sponsor_code)
|
|
78
|
+
assert not result
|
|
79
|
+
assert message == "sponsor_code is required"
|
|
80
|
+
|
|
81
|
+
@pytest.mark.vcr()
|
|
82
|
+
def test_check_sponsor_code_ko_code_not_found(self):
|
|
83
|
+
sponsor_code = "XXXXX"
|
|
84
|
+
result, message = Partner.check_sponsor_code(sponsor_code)
|
|
85
|
+
assert not result
|
|
86
|
+
assert message == "invalid code"
|
|
87
|
+
|
|
88
|
+
@pytest.mark.vcr()
|
|
89
|
+
def test_check_sponsor_code_ok(self):
|
|
90
|
+
sponsor_code = "KPWMO"
|
|
91
|
+
result, message = Partner.check_sponsor_code(sponsor_code)
|
|
92
|
+
assert result
|
|
93
|
+
assert message == "ok"
|
|
94
|
+
|
|
65
95
|
@pytest.mark.vcr()
|
|
66
96
|
def test_get_sponsees_not_found(self):
|
|
67
97
|
self.assertRaises(ResourceNotFound, Partner.sponsees, ref="NOT_EXISTS")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|