Skip to content

Commit

Permalink
Now addons returns an empty dict instead of None to remain consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
llacroix committed Mar 4, 2023
1 parent fa878a9 commit 834d6eb
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 7 deletions.
Empty file.
4 changes: 2 additions & 2 deletions odoo_tools/configuration/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def fetch_addons(addon, output_directory, decrypt_key=None, credentials=None):

url = urlparse(parsed.url2https)

_logger.debug("Fetching with url: %s", url.geturl())

url = url._replace(
netloc="{}:{}@{}".format(
username,
password,
host
)
).geturl()

_logger.debug("Fetching with url: %s", url)
else:
url = origin_url

Expand Down
26 changes: 22 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import setuptools
from pathlib import Path

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


def find_in_path(module, path):
def find_files(cur_path):
files = []
for path in cur_path.iterdir():
if not path.is_dir():
files.append(str(path))
else:
files += find_files(path)
return files

module_path = Path.cwd() / module / path

return find_files(module_path)


setuptools.setup(
name="odoo-tools",
version="0.1.7",
Expand Down Expand Up @@ -79,9 +96,10 @@
]
},
package_data={
"odoo_tools": [
"requirements/*.txt",
"packages/*.toml",
],
"odoo_tools": (
find_in_path('odoo_tools', 'requirements') +
find_in_path('odoo_tools', 'overlays') +
find_in_path('odoo_tools', 'packages')
)
}
)
72 changes: 72 additions & 0 deletions tests/cli/test_services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from mock import patch, MagicMock
from odoo_tools.cli.odot import command
from odoo_tools.api.services import ServiceApi


def test_service_package(runner):

with patch.object(ServiceApi, 'get_services') as get_services, \
patch.object(ServiceApi, 'package') as package:
manifests = MagicMock()
get_services.return_value = manifests
package.return_value = []

result = runner.invoke(
command,
[
'service',
'package',
'service.toml',
'odoo',
]
)

assert result.exception is None
manifests.services.get.assert_called_with('odoo')
service = manifests.services.get('odoo').resolved

package.assert_called_with(
service,
None, # output
None, # cache
None # decrypt_key
)


def test_service_checkout(runner):

with patch.object(ServiceApi, 'get_services') as get_services, \
patch.object(ServiceApi, 'checkout') as checkout:

manifests = MagicMock()
get_services.return_value = manifests

result = runner.invoke(
command,
[
'service',
'checkout',
'--cache', 'cache',
'--credentials', 'a:b:c',
'service.toml',
'odoo',
'addons'
]
)

assert result.exception is None
manifests.services.get.assert_called_with('odoo')
service = manifests.services.get('odoo').resolved

checkout.assert_called_with(
service,
'addons',
'cache',
None,
{
'a': {
"username": "b",
"password": "c"
}
}
)
2 changes: 1 addition & 1 deletion tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_service_no_inheritance():
manifest = ServiceManifests.parse(inheritance_services)

assert len(manifest.services) == 4
assert manifest.services['prod'].addons is None
assert manifest.services['prod'].addons == {}
assert len(manifest.services['prod2'].addons) == 0
assert len(manifest.services['dev'].addons) == 2
assert len(manifest.services['base'].addons) == 1
Expand Down

0 comments on commit 834d6eb

Please sign in to comment.