Skip to content

Commit 834d6eb

Browse files
committed
Now addons returns an empty dict instead of None to remain consistent
1 parent fa878a9 commit 834d6eb

File tree

5 files changed

+97
-7
lines changed

5 files changed

+97
-7
lines changed

odoo_tools/app/mixins/__init__.py

Whitespace-only changes.

odoo_tools/configuration/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ def fetch_addons(addon, output_directory, decrypt_key=None, credentials=None):
7070

7171
url = urlparse(parsed.url2https)
7272

73-
_logger.debug("Fetching with url: %s", url.geturl())
74-
7573
url = url._replace(
7674
netloc="{}:{}@{}".format(
7775
username,
7876
password,
7977
host
8078
)
8179
).geturl()
80+
81+
_logger.debug("Fetching with url: %s", url)
8282
else:
8383
url = origin_url
8484

setup.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
import setuptools
2+
from pathlib import Path
23

34
with open("README.md", "r") as fh:
45
long_description = fh.read()
56

7+
8+
def find_in_path(module, path):
9+
def find_files(cur_path):
10+
files = []
11+
for path in cur_path.iterdir():
12+
if not path.is_dir():
13+
files.append(str(path))
14+
else:
15+
files += find_files(path)
16+
return files
17+
18+
module_path = Path.cwd() / module / path
19+
20+
return find_files(module_path)
21+
22+
623
setuptools.setup(
724
name="odoo-tools",
825
version="0.1.7",
@@ -79,9 +96,10 @@
7996
]
8097
},
8198
package_data={
82-
"odoo_tools": [
83-
"requirements/*.txt",
84-
"packages/*.toml",
85-
],
99+
"odoo_tools": (
100+
find_in_path('odoo_tools', 'requirements') +
101+
find_in_path('odoo_tools', 'overlays') +
102+
find_in_path('odoo_tools', 'packages')
103+
)
86104
}
87105
)

tests/cli/test_services.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from mock import patch, MagicMock
2+
from odoo_tools.cli.odot import command
3+
from odoo_tools.api.services import ServiceApi
4+
5+
6+
def test_service_package(runner):
7+
8+
with patch.object(ServiceApi, 'get_services') as get_services, \
9+
patch.object(ServiceApi, 'package') as package:
10+
manifests = MagicMock()
11+
get_services.return_value = manifests
12+
package.return_value = []
13+
14+
result = runner.invoke(
15+
command,
16+
[
17+
'service',
18+
'package',
19+
'service.toml',
20+
'odoo',
21+
]
22+
)
23+
24+
assert result.exception is None
25+
manifests.services.get.assert_called_with('odoo')
26+
service = manifests.services.get('odoo').resolved
27+
28+
package.assert_called_with(
29+
service,
30+
None, # output
31+
None, # cache
32+
None # decrypt_key
33+
)
34+
35+
36+
def test_service_checkout(runner):
37+
38+
with patch.object(ServiceApi, 'get_services') as get_services, \
39+
patch.object(ServiceApi, 'checkout') as checkout:
40+
41+
manifests = MagicMock()
42+
get_services.return_value = manifests
43+
44+
result = runner.invoke(
45+
command,
46+
[
47+
'service',
48+
'checkout',
49+
'--cache', 'cache',
50+
'--credentials', 'a:b:c',
51+
'service.toml',
52+
'odoo',
53+
'addons'
54+
]
55+
)
56+
57+
assert result.exception is None
58+
manifests.services.get.assert_called_with('odoo')
59+
service = manifests.services.get('odoo').resolved
60+
61+
checkout.assert_called_with(
62+
service,
63+
'addons',
64+
'cache',
65+
None,
66+
{
67+
'a': {
68+
"username": "b",
69+
"password": "c"
70+
}
71+
}
72+
)

tests/test_services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_service_no_inheritance():
108108
manifest = ServiceManifests.parse(inheritance_services)
109109

110110
assert len(manifest.services) == 4
111-
assert manifest.services['prod'].addons is None
111+
assert manifest.services['prod'].addons == {}
112112
assert len(manifest.services['prod2'].addons) == 0
113113
assert len(manifest.services['dev'].addons) == 2
114114
assert len(manifest.services['base'].addons) == 1

0 commit comments

Comments
 (0)