Skip to content

Commit e5db120

Browse files
committed
WIP: Testing now runs the s3 specific tests
1 parent af35009 commit e5db120

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

.github/workflows/python-static-analysis-and-test.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,21 @@ jobs:
4949
strategy:
5050
matrix:
5151
# Test if using native json or pyjson5 for json parsing
52-
json_ver: ['json', 'json5']
52+
pkg_mods: ['json', 'json5', 's3']
5353
os: ['ubuntu-latest', 'windows-latest']
54-
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
54+
python: ['3.8', '3.9', '3.10', '3.11']
55+
# Works around the depreciation of python 3.6 for ubuntu
56+
# https://github.com/actions/setup-python/issues/544
57+
include:
58+
- pkg_mods: 'json'
59+
os: 'ubuntu-22.04'
60+
python: '3.7'
61+
- pkg_mods: 'json5'
62+
os: 'ubuntu-22.04'
63+
python: '3.7'
64+
- pkg_mods: 's3'
65+
os: 'ubuntu-22.04'
66+
python: '3.7'
5567

5668
runs-on: ${{ matrix.os }}
5769

@@ -71,12 +83,12 @@ jobs:
7183
7284
- name: Run Tox
7385
run: |
74-
tox -e begin,py-${{ matrix.json_ver }}
86+
tox -e begin,py-${{ matrix.pkg_mods }}
7587
7688
- name: Upload coverage
7789
uses: actions/upload-artifact@v4
7890
with:
79-
name: coverage-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.json_ver }}
91+
name: coverage-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.pkg_mods }}
8092
path: .coverage.*
8193
include-hidden-files: true
8294
retention-days: 1

tests/test_distro_finder.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,38 @@ def test_install(self, zip_distro, helpers, tmp_path):
302302
class TestS3(CheckDistroFinder):
303303
"""Tests specific to `DistroFinderS3Zip`."""
304304

305-
distro_finder_cls = df_zip.DistroFinderZip
306305
site_template = "site_distro_s3.json"
307306

307+
@property
308+
def distro_finder_cls(self):
309+
"""Only import this class if the test is not skipped."""
310+
from hab.distro_finders.s3_zip import DistroFinderS3Zip
311+
312+
return DistroFinderS3Zip
313+
308314
def test_installed(self, zip_distro_s3, helpers, tmp_path):
309315
self.check_installed(zip_distro_s3, helpers, tmp_path)
310316

311317
def test_install(self, zip_distro_s3, helpers, tmp_path):
312318
self.check_install(zip_distro_s3, helpers, tmp_path)
313319

320+
def test_client(self, zip_distro_s3, helpers, tmp_path):
321+
"""Test `DistroFinderS3Zip.client` edge cases."""
322+
default_cache_dir = utils.Platform.default_download_cache()
323+
# Test if `site.downloads["cache_root"]` is not set
324+
finder = self.distro_finder_cls("s3://hab-test-bucket")
325+
assert finder.client._local_cache_dir == default_cache_dir
326+
327+
# Test if `site.downloads["cache_root"]` is set
328+
resolver = self.create_resolver(zip_distro_s3.root, helpers, tmp_path)
329+
finder = self.distro_finder_cls("s3://hab-test-bucket", site=resolver.site)
330+
cache_dir = resolver.site["downloads"]["cache_root"]
331+
assert finder.client._local_cache_dir == cache_dir
332+
333+
# Test the client setter
334+
finder.client = "A custom client"
335+
assert finder.client == "A custom client"
336+
314337

315338
# TODO: Break this into separate smaller tests of components for each class not this
316339
@pytest.mark.parametrize(

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ depends = begin
3737
basepython = python3
3838
depends =
3939
begin
40-
py{37,38,39,310,311}-{json,json5}
40+
py{37,38,39,310,311}-{json,json5,s3}
4141
parallel_show_output = True
4242
deps =
4343
coverage

0 commit comments

Comments
 (0)