-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from ceph/wip-fix-tox
Fix tox tests and enable actions
- Loading branch information
Showing
6 changed files
with
68 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: ci | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: CI on python${{ matrix.python }} via ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-22.04 | ||
python: "3.10" | ||
- os: ubuntu-22.04 | ||
python: "3.11" | ||
- os: ubuntu-24.04 | ||
python: "3.12" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
- name: Install system deps | ||
run: sudo apt-get -y install libvirt-dev | ||
- name: Install tox | ||
run: pip install tox | ||
- name: Run unit tests | ||
run: tox -e py3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,22 @@ | ||
from .. import discover | ||
from unittest.mock import patch, Mock | ||
|
||
@patch('requests.get') | ||
def test_ubuntu_handler(m_requests_get): | ||
h = discover.UbuntuHandler() | ||
assert 'focal' == h.get_release('20.04') | ||
assert '18.04' == h.get_version('bionic') | ||
m_request = Mock() | ||
m_request.content = ( | ||
b"focal server release 20230302\n" | ||
b"jammy server release 20230303\n") | ||
m_requests_get.return_value = m_request | ||
assert ('20230302','release') == h.get_serial('focal') | ||
|
||
@patch('downburst.discover.UbuntuHandler.get_serial') | ||
def test_get(m_get_serial): | ||
m_get_serial.return_value = ('20230420', 'release') | ||
checksum = 'cd824b19795e8a6b9ae993b0b5157de0275e952a7a9e8b9717ca07acec22f51b' | ||
res = discover.get('ubuntu', '20.04', 'x86_64') | ||
assert checksum == res['checksum'] | ||
|
||
def test_extract(): | ||
PATH = ( | ||
'server/releases/precise/release-20120424' | ||
+ '/ubuntu-12.04-server-cloudimg-amd64-disk1.img' | ||
) | ||
URL = 'https://cloud-images.ubuntu.com/' + PATH | ||
SHA512 = ( | ||
'0737607be5c9b8ef9b7c45a77802b0098ce99d73' | ||
+ '7e1a233e1e582f98ea10b6619dcb280bb7e5c6ce' | ||
+ 'fcba275473e9be56a7058fea534db7534908d3d0' | ||
+ '83c569bd' | ||
) | ||
catalog = dict( | ||
catalog=[ | ||
dict( | ||
distro_code_name='oneiric', | ||
borkbork=True, | ||
), | ||
dict( | ||
distro_code_name='precise', | ||
build_types=dict( | ||
misleading='bork bork', | ||
server=[ | ||
dict( | ||
release_tag='daily', | ||
borkbork=True, | ||
), | ||
dict( | ||
release_tag='release', | ||
build_serial='20120424', | ||
arches=dict( | ||
misleading='bork bork', | ||
amd64=dict( | ||
file_list=[ | ||
dict( | ||
file_type='tar.gz', | ||
borkbork=True, | ||
), | ||
dict( | ||
file_type='qcow2', | ||
build_serial='20120424', | ||
path=PATH, | ||
sha512=SHA512, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
) | ||
got = discover.extract(catalog) | ||
assert got is not None | ||
assert got == dict( | ||
serial='20120424', | ||
url=URL, | ||
sha512=SHA512, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
[tox] | ||
envlist = py27 | ||
envlist = py3 | ||
|
||
[testenv] | ||
deps= | ||
-r{toxinidir}/requirements-dev.txt | ||
requests | ||
lxml | ||
pytest | ||
|