diff --git a/odoo_tools/app/mixins/__init__.py b/odoo_tools/app/mixins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/odoo_tools/configuration/git.py b/odoo_tools/configuration/git.py index 6c67616..f275c31 100644 --- a/odoo_tools/configuration/git.py +++ b/odoo_tools/configuration/git.py @@ -70,8 +70,6 @@ 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, @@ -79,6 +77,8 @@ def fetch_addons(addon, output_directory, decrypt_key=None, credentials=None): host ) ).geturl() + + _logger.debug("Fetching with url: %s", url) else: url = origin_url diff --git a/setup.py b/setup.py index 44c36c6..c6a659c 100644 --- a/setup.py +++ b/setup.py @@ -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", @@ -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') + ) } ) diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py new file mode 100644 index 0000000..37f267f --- /dev/null +++ b/tests/cli/test_services.py @@ -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" + } + } + ) diff --git a/tests/test_services.py b/tests/test_services.py index fa892fb..0e9b1cf 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -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