-
Notifications
You must be signed in to change notification settings - Fork 0
Add tests #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add tests #2
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
11332f9
Add tests
thopkins32 b00b7c5
Merge branch 'main' of github.com:NSLS2/tst-sim-tools into tests
thopkins32 69c4ba8
Fix thread joining in conftest.py
thopkins32 ef4e783
Fix typo in test function name for aperture
thopkins32 8c0f0ba
Fixed tests and responded to feedback
thopkins32 a60adea
Merge branch 'tests' of github.com:NSLS2/tst-sim-tools into tests
thopkins32 82ff383
Update badge for unit tests in README.md
thopkins32 8bd44c7
Add timeout to polling Tiled
thopkins32 05dacfb
Merge branch 'tests' of github.com:NSLS2/tst-sim-tools into tests
thopkins32 400cb0e
Proper timeout handling of Tiled access
thopkins32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,32 @@ | ||
| name: Daily integration tests | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "17 6 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| integration: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Pixi environment | ||
| uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e | ||
| with: | ||
| pixi-version: v0.77.0 | ||
| manifest-path: pyproject.toml | ||
| environments: dev | ||
| locked: true | ||
| cache: true | ||
|
|
||
| - name: Run integration tests | ||
| run: pixi run -e dev test-integration |
This file contains hidden or 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: Unit tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| unit: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Pixi environment | ||
| uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e | ||
| with: | ||
| pixi-version: v0.77.0 | ||
| manifest-path: pyproject.toml | ||
| environments: dev | ||
| locked: true | ||
| cache: true | ||
|
|
||
| - name: Run unit tests | ||
| run: pixi run -e dev test-unit |
This file contains hidden or 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,3 +1,5 @@ | ||
| # tst-sim-tools | ||
|
|
||
| [](https://github.com/NSLS2/tst-sim-tools/actions/workflows/unit-tests.yml) | ||
|
|
||
| Tools for the TST beamline's simulated "endstation" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| import asyncio | ||
| import os | ||
| from collections import defaultdict | ||
| from collections.abc import Generator | ||
|
|
||
| os.environ.setdefault("MPLBACKEND", "Agg") | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| import pytest | ||
| from bluesky import RunEngine | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def close_figures() -> Generator[None]: | ||
| """Close every Matplotlib figure after each test.""" | ||
| yield | ||
| plt.close("all") | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def run_engine() -> Generator[RunEngine]: | ||
| """Provide a RunEngine with an isolated, deterministically closed loop.""" | ||
| loop = asyncio.new_event_loop() | ||
| engine = RunEngine({}, call_returns_result=True, loop=loop) | ||
| try: | ||
| yield engine | ||
| finally: | ||
| if engine.state not in ("idle", "panicked"): | ||
| try: | ||
| engine.halt() | ||
| except RuntimeError: | ||
| pass | ||
| loop.call_soon_threadsafe(loop.stop) | ||
| thread = getattr(engine, "_th", None) | ||
| if thread is not None: | ||
| thread.join() | ||
| loop.close() | ||
|
Copilot marked this conversation as resolved.
|
||
|
|
||
|
|
||
| @pytest.fixture | ||
| def documents(): | ||
| """Collect emitted Bluesky documents by name.""" | ||
| collected = defaultdict(list) | ||
|
|
||
| def collect(name, document): | ||
| collected[name].append(document) | ||
|
|
||
| return collected, collect | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.