Skip to content

Commit

Permalink
WIP: Testing now runs the s3 specific tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MHendricks committed Jan 18, 2025
1 parent 2daa646 commit 66629c7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/python-static-analysis-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
Expand Down
25 changes: 24 additions & 1 deletion tests/test_distro_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 66629c7

Please sign in to comment.