diff --git a/prestashop_docker/version_manager.py b/prestashop_docker/version_manager.py index b05d0f44..a2697406 100644 --- a/prestashop_docker/version_manager.py +++ b/prestashop_docker/version_manager.py @@ -62,22 +62,24 @@ def parse_version(self, version): @rtype: dict ''' - data = self.get_version_from_string(version) - if data is None or not (self.directory_path / data['ps_version']).exists(): + # Initial PS version(can also be a branch like 9.0.x) + split_version = self.split_prestashop_version(version) + if split_version is None or not (self.directory_path / split_version['version']).exists(): raise ValueError('{} is not a valid version'.format(version)) - if data['container_version'] is None: + data = self.get_version_from_string(version) + if data is None or data['container_version'] is None: containers = ('fpm', 'apache',) else: containers = (data['container_version'],) - ps_version_path = self.directory_path / data['ps_version'] + ps_version_path = self.directory_path / split_version['version'] result = {} for php_version in data['php_versions']: for container in containers: container_path = ps_version_path / (php_version + '-' + container) if container_path.exists(): - result[self.create_version(data['ps_version'], php_version, container)] = str(container_path) + result[self.create_version(split_version['version'], php_version, container)] = str(container_path) return result diff --git a/tests/prestashop_docker/test_version_manager.py b/tests/prestashop_docker/test_version_manager.py index 361123a0..be12be55 100644 --- a/tests/prestashop_docker/test_version_manager.py +++ b/tests/prestashop_docker/test_version_manager.py @@ -27,6 +27,8 @@ def setUp(self, docker_api): self.fs.create_dir('/tmp/images/9.0.x/8.1-apache') self.fs.create_dir('/tmp/images/9.0.x/8.2-fpm') self.fs.create_dir('/tmp/images/9.0.x/8.2-apache') + self.fs.create_dir('/tmp/images/9.0.x/8.3-fpm') + self.fs.create_dir('/tmp/images/9.0.x/8.3-apache') self.fs.create_dir('/tmp/images/nightly/7.1-fpm') self.fs.create_dir('/tmp/images/nightly/7.1-apache') self.version_manager = self.create_instance() @@ -186,6 +188,11 @@ def test_get_version_from_string_with_container_version(self): {'ps_version': '8.0.0', 'branch_version': '8.0.x', 'php_versions': ('7.2',), 'container_version': None}, result ) + result = self.version_manager.get_version_from_string('9.0.x-8.2') + self.assertEqual( + {'ps_version': '9.0.0', 'branch_version': '9.0.x', 'php_versions': ('8.2',), 'container_version': None}, + result + ) @patch('prestashop_docker.version_manager.VERSIONS', all_versions) def test_get_version_from_string_with_container_version_and_type(self): @@ -199,6 +206,11 @@ def test_get_version_from_string_with_container_version_and_type(self): {'ps_version': '8.0.0', 'branch_version': '8.0.x', 'php_versions': ('7.2',), 'container_version': 'fpm'}, result ) + result = self.version_manager.get_version_from_string('9.0.x-8.2-fpm') + self.assertEqual( + {'ps_version': '9.0.0', 'branch_version': '9.0.x', 'php_versions': ('8.2',), 'container_version': 'fpm'}, + result + ) @patch('prestashop_docker.version_manager.VERSIONS', all_versions) def test_get_version_from_string_with_pre_release_and_without_container_version_and_type(self): @@ -264,6 +276,17 @@ def test_parse_version_with_valid_version(self): }, self.version_manager.parse_version('8.0.0') ) + self.assertEqual( + { + '9.0.x-8.1-apache': '/tmp/images/9.0.x/8.1-apache', + '9.0.x-8.1-fpm': '/tmp/images/9.0.x/8.1-fpm', + '9.0.x-8.2-apache': '/tmp/images/9.0.x/8.2-apache', + '9.0.x-8.2-fpm': '/tmp/images/9.0.x/8.2-fpm', + '9.0.x-8.3-apache': '/tmp/images/9.0.x/8.3-apache', + '9.0.x-8.3-fpm': '/tmp/images/9.0.x/8.3-fpm', + }, + self.version_manager.parse_version('9.0.x') + ) @patch('prestashop_docker.version_manager.VERSIONS', all_versions) def test_parse_version_with_valid_version_and_php_version(self): @@ -281,6 +304,13 @@ def test_parse_version_with_valid_version_and_php_version(self): }, self.version_manager.parse_version('8.1.0-7.2') ) + self.assertEqual( + { + '9.0.x-8.2-apache': '/tmp/images/9.0.x/8.2-apache', + '9.0.x-8.2-fpm': '/tmp/images/9.0.x/8.2-fpm', + }, + self.version_manager.parse_version('9.0.x-8.2') + ) @patch('prestashop_docker.version_manager.VERSIONS', all_versions) def test_parse_version_with_valid_version_php_version_and_container(self): @@ -296,6 +326,12 @@ def test_parse_version_with_valid_version_php_version_and_container(self): }, self.version_manager.parse_version('8.1.3-7.2-apache') ) + self.assertEqual( + { + '9.0.x-8.2-apache': '/tmp/images/9.0.x/8.2-apache', + }, + self.version_manager.parse_version('9.0.x-8.2-apache') + ) @patch('prestashop_docker.version_manager.VERSIONS', all_versions) def test_get_versions(self):