-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FIX: Rework `setup()` to allow overriding options * FIX: Use string representation of UUIDs, clean up load * RF: Rework `Config.init()` logic * TST: Add configuration testing * TST: Add GH actions workflow
- Loading branch information
Showing
5 changed files
with
185 additions
and
23 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,62 @@ | ||
name: install-test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- master | ||
schedule: | ||
# 7am EST / 8am EDT Mondays | ||
- cron: '0 12 * * 1' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8, 3.9, 3.10] | ||
install: [repo] | ||
pip-flags: ['', '--pre'] | ||
include: | ||
- python-version: 3.9 | ||
install: sdist | ||
pip-flags: '' | ||
- python-version: 3.9 | ||
install: wheel | ||
pip-flags: '' | ||
- python-version: 3.9 | ||
install: editable | ||
pip-flags: '' | ||
|
||
env: | ||
INSTALL_TYPE: ${{ matrix.install }} | ||
PIP_FLAGS: ${{ matrix.pip-flags }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Select archive | ||
run: | | ||
if [ "$INSTALL_TYPE" = "sdist" ]; then | ||
ARCHIVE=$( ls dist/*.tar.gz ) | ||
elif [ "$INSTALL_TYPE" = "wheel" ]; then | ||
ARCHIVE=$( ls dist/*.whl ) | ||
elif [ "$INSTALL_TYPE" = "repo" ]; then | ||
ARCHIVE="." | ||
elif [ "$INSTALL_TYPE" = "editable" ]; then | ||
ARCHIVE="-e ." | ||
fi | ||
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV | ||
- name: Install package and test dependencies | ||
run: python -m pip install $PIP_FLAGS $ARCHIVE[test] | ||
- name: Run tests | ||
run: python -m pytest -sv --doctest-modules etelemetry |
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
Empty file.
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,37 @@ | ||
import uuid | ||
|
||
import pytest | ||
|
||
from .. import config | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def tmp_config(tmp_path, monkeypatch): | ||
home = tmp_path / 'config.json' | ||
monkeypatch.setattr(config, 'DEFAULT_CONFIG_FILE', home) | ||
|
||
|
||
def test_setup_default(): | ||
|
||
conf = config.Config | ||
assert conf.endpoint is None | ||
assert conf.user_id is None | ||
assert conf.session_id is None | ||
assert conf._is_setup is False | ||
|
||
config.setup() | ||
assert conf.endpoint == config.DEFAULT_ENDPOINT | ||
assert uuid.UUID(conf.user_id) | ||
assert conf.session_id is None | ||
assert conf._is_setup is True | ||
|
||
# after being set up, cannot be overriden | ||
new_endpoint = 'https://github.com' | ||
config.setup(endpoint=new_endpoint) | ||
assert conf.endpoint == config.DEFAULT_ENDPOINT | ||
|
||
# but fine if cleared | ||
conf._reset() | ||
assert conf.endpoint is None | ||
config.setup(endpoint=new_endpoint) | ||
assert conf.endpoint == new_endpoint |
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