diff --git a/.github/workflows/python-static-analysis-and-test.yml b/.github/workflows/python-static-analysis-and-test.yml index b8ee105..656b55c 100644 --- a/.github/workflows/python-static-analysis-and-test.yml +++ b/.github/workflows/python-static-analysis-and-test.yml @@ -49,9 +49,21 @@ jobs: strategy: matrix: # Test if using native json or pyjson5 for json parsing - json_ver: ['json', 'json5'] + pkg_mods: ['json', 'json5', 's3'] os: ['ubuntu-latest', 'windows-latest'] - python: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python: ['3.8', '3.9', '3.10', '3.11'] + # Works around the depreciation of python 3.6 for ubuntu + # https://github.com/actions/setup-python/issues/544 + include: + - pkg_mods: 'json' + os: 'ubuntu-22.04' + python: '3.7' + - pkg_mods: 'json5' + os: 'ubuntu-22.04' + python: '3.7' + - pkg_mods: 's3' + os: 'ubuntu-22.04' + python: '3.7' runs-on: ${{ matrix.os }} @@ -71,12 +83,12 @@ jobs: - name: Run Tox run: | - tox -e begin,py-${{ matrix.json_ver }} + tox -e begin,py-${{ matrix.pkg_mods }} - name: Upload coverage uses: actions/upload-artifact@v4 with: - name: coverage-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.json_ver }} + name: coverage-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.pkg_mods }} path: .coverage.* include-hidden-files: true retention-days: 1 diff --git a/tests/test_distro_finder.py b/tests/test_distro_finder.py index 9eb9394..b7aab38 100644 --- a/tests/test_distro_finder.py +++ b/tests/test_distro_finder.py @@ -302,15 +302,38 @@ def test_install(self, zip_distro, helpers, tmp_path): class TestS3(CheckDistroFinder): """Tests specific to `DistroFinderS3Zip`.""" - distro_finder_cls = df_zip.DistroFinderZip site_template = "site_distro_s3.json" + @property + def distro_finder_cls(self): + """Only import this class if the test is not skipped.""" + from hab.distro_finders.s3_zip import DistroFinderS3Zip + + return DistroFinderS3Zip + def test_installed(self, zip_distro_s3, helpers, tmp_path): self.check_installed(zip_distro_s3, helpers, tmp_path) def test_install(self, zip_distro_s3, helpers, tmp_path): self.check_install(zip_distro_s3, helpers, tmp_path) + def test_client(self, zip_distro_s3, helpers, tmp_path): + """Test `DistroFinderS3Zip.client` edge cases.""" + default_cache_dir = utils.Platform.default_download_cache() + # Test if `site.downloads["cache_root"]` is not set + finder = self.distro_finder_cls("s3://hab-test-bucket") + assert finder.client._local_cache_dir == default_cache_dir + + # Test if `site.downloads["cache_root"]` is set + resolver = self.create_resolver(zip_distro_s3.root, helpers, tmp_path) + finder = self.distro_finder_cls("s3://hab-test-bucket", site=resolver.site) + cache_dir = resolver.site["downloads"]["cache_root"] + assert finder.client._local_cache_dir == cache_dir + + # Test the client setter + finder.client = "A custom client" + assert finder.client == "A custom client" + # TODO: Break this into separate smaller tests of components for each class not this @pytest.mark.parametrize( diff --git a/tox.ini b/tox.ini index bb5e027..d564fac 100644 --- a/tox.ini +++ b/tox.ini @@ -37,7 +37,7 @@ depends = begin basepython = python3 depends = begin - py{37,38,39,310,311}-{json,json5} + py{37,38,39,310,311}-{json,json5,s3} parallel_show_output = True deps = coverage