init repo
This commit is contained in:
3
.git_hooks/post-commit
Normal file
3
.git_hooks/post-commit
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
semantic-release changelog -D version_variable=$SCRIPT_DIR/../../semantic_release/__init__.py:__version__
|
||||||
|
semantic-release version -D version_variable=$SCRIPT_DIR/../../semantic_release/__init__.py:__version__
|
3
.git_hooks/pre-commit
Normal file
3
.git_hooks/pre-commit
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
black --line-length=100 $(git diff --cached --name-only --diff-filter=ACM -- '*.py')
|
||||||
|
isort --line-length=100 --profile=black --multi-line=3 --trailing-comma $(git diff --cached --name-only --diff-filter=ACM -- '*.py')
|
||||||
|
git add $(git diff --cached --name-only --diff-filter=ACM -- '*.py')
|
180
.gitignore
vendored
Normal file
180
.gitignore
vendored
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
**/*_venv
|
||||||
|
**/.idea
|
||||||
|
*.log
|
||||||
|
**/__pycache__
|
||||||
|
**/.DS_Store
|
||||||
|
**/out
|
||||||
|
**/.vscode
|
||||||
|
**/.pytest_cache
|
||||||
|
**/*.egg*
|
||||||
|
|
||||||
|
# recovery_config files
|
||||||
|
recovery_config_*
|
||||||
|
|
||||||
|
# file writer data
|
||||||
|
**.h5
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/**/_build/
|
||||||
|
docs/**/autodoc/
|
||||||
|
docs/**/_autosummary/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
**.prof
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/#use-with-ide
|
||||||
|
.pdm.toml
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
6
.gitlab-ci.yml
Normal file
6
.gitlab-ci.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
include:
|
||||||
|
- file: /templates/plugin-repo-template.yml
|
||||||
|
inputs:
|
||||||
|
name: phoenix_bec
|
||||||
|
target: phoenix_bec
|
||||||
|
project: bec/awi_utils
|
0
phoenix_bec/__init__.py
Normal file
0
phoenix_bec/__init__.py
Normal file
0
phoenix_bec/bec_ipython_client/__init__.py
Normal file
0
phoenix_bec/bec_ipython_client/__init__.py
Normal file
0
phoenix_bec/bec_ipython_client/plugins/__init__.py
Normal file
0
phoenix_bec/bec_ipython_client/plugins/__init__.py
Normal file
0
phoenix_bec/bec_ipython_client/startup/__init__.py
Normal file
0
phoenix_bec/bec_ipython_client/startup/__init__.py
Normal file
36
phoenix_bec/bec_ipython_client/startup/post_startup.py
Normal file
36
phoenix_bec/bec_ipython_client/startup/post_startup.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
"""
|
||||||
|
Post startup script for the BEC client. This script is executed after the
|
||||||
|
IPython shell is started. It is used to load the beamline specific
|
||||||
|
information and to setup the prompts.
|
||||||
|
|
||||||
|
The script is executed in the global namespace of the IPython shell. This
|
||||||
|
means that all variables defined here are available in the shell.
|
||||||
|
|
||||||
|
While command-line arguments have to be set in the pre-startup script, the
|
||||||
|
post-startup script can be used to load beamline specific information and
|
||||||
|
to setup the prompts.
|
||||||
|
|
||||||
|
from bec_lib.logger import bec_logger
|
||||||
|
|
||||||
|
logger = bec_logger.logger
|
||||||
|
|
||||||
|
# pylint: disable=import-error
|
||||||
|
_args = _main_dict["args"]
|
||||||
|
|
||||||
|
_session_name = "cSAXS"
|
||||||
|
if _args.session.lower() == "lamni":
|
||||||
|
from csaxs_bec.bec_ipython_client.plugins.cSAXS import *
|
||||||
|
from csaxs_bec.bec_ipython_client.plugins.LamNI import *
|
||||||
|
|
||||||
|
_session_name = "LamNI"
|
||||||
|
lamni = LamNI(bec)
|
||||||
|
logger.success("LamNI session loaded.")
|
||||||
|
|
||||||
|
elif _args.session.lower() == "csaxs":
|
||||||
|
print("Loading cSAXS session")
|
||||||
|
from csaxs_bec.bec_ipython_client.plugins.cSAXS import *
|
||||||
|
|
||||||
|
logger.success("cSAXS session loaded.")
|
||||||
|
"""
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name, unused-import, import-error, undefined-variable, unused-variable, unused-argument, no-name-in-module
|
23
phoenix_bec/bec_ipython_client/startup/pre_startup.py
Normal file
23
phoenix_bec/bec_ipython_client/startup/pre_startup.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
"""
|
||||||
|
Pre-startup script for BEC client. This script is executed before the BEC client
|
||||||
|
is started. It can be used to add additional command line arguments.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from bec_lib.service_config import ServiceConfig
|
||||||
|
|
||||||
|
|
||||||
|
def extend_command_line_args(parser):
|
||||||
|
"""
|
||||||
|
Extend the command line arguments of the BEC client.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# parser.add_argument("--session", help="Session name", type=str, default="cSAXS")
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
# def get_config() -> ServiceConfig:
|
||||||
|
# """
|
||||||
|
# Create and return the service configuration.
|
||||||
|
# """
|
||||||
|
# return ServiceConfig(redis={"host": "localhost", "port": 6379})
|
0
phoenix_bec/bec_widgets/__init__.py
Normal file
0
phoenix_bec/bec_widgets/__init__.py
Normal file
0
phoenix_bec/bec_widgets/widgets/__init__.py
Normal file
0
phoenix_bec/bec_widgets/widgets/__init__.py
Normal file
0
phoenix_bec/deployments/__init__.py
Normal file
0
phoenix_bec/deployments/__init__.py
Normal file
0
phoenix_bec/deployments/device_server/__init__.py
Normal file
0
phoenix_bec/deployments/device_server/__init__.py
Normal file
11
phoenix_bec/deployments/device_server/startup.py
Normal file
11
phoenix_bec/deployments/device_server/startup.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def setup_epics_ca():
|
||||||
|
# os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO"
|
||||||
|
# os.environ["EPICS_CA_ADDR_LIST"] = "129.129.122.255 sls-x12sa-cagw.psi.ch:5836"
|
||||||
|
os.environ["PYTHONIOENCODING"] = "latin1"
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
setup_epics_ca()
|
0
phoenix_bec/device_configs/__init__.py
Normal file
0
phoenix_bec/device_configs/__init__.py
Normal file
0
phoenix_bec/devices/__init__.py
Normal file
0
phoenix_bec/devices/__init__.py
Normal file
0
phoenix_bec/file_writer/__init__.py
Normal file
0
phoenix_bec/file_writer/__init__.py
Normal file
0
phoenix_bec/scans/__init__.py
Normal file
0
phoenix_bec/scans/__init__.py
Normal file
34
phoenix_bec/scans/scan_plugin_template.py
Normal file
34
phoenix_bec/scans/scan_plugin_template.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
SCAN PLUGINS
|
||||||
|
|
||||||
|
All new scans should be derived from ScanBase. ScanBase provides various methods that can be customized and overriden
|
||||||
|
but they are executed in a specific order:
|
||||||
|
|
||||||
|
- self.initialize # initialize the class if needed
|
||||||
|
- self.read_scan_motors # used to retrieve the start position (and the relative position shift if needed)
|
||||||
|
- self.prepare_positions # prepare the positions for the scan. The preparation is split into multiple sub fuctions:
|
||||||
|
- self._calculate_positions # calculate the positions
|
||||||
|
- self._set_positions_offset # apply the previously retrieved scan position shift (if needed)
|
||||||
|
- self._check_limits # tests to ensure the limits won't be reached
|
||||||
|
- self.open_scan # send an open_scan message including the scan name, the number of points and the scan motor names
|
||||||
|
- self.stage # stage all devices for the upcoming acquisiton
|
||||||
|
- self.run_baseline_readings # read all devices to get a baseline for the upcoming scan
|
||||||
|
- self.pre_scan # perform additional actions before the scan starts
|
||||||
|
- self.scan_core # run a loop over all position
|
||||||
|
- self._at_each_point(ind, pos) # called at each position with the current index and the target positions as arguments
|
||||||
|
- self.finalize # clean up the scan, e.g. move back to the start position; wait everything to finish
|
||||||
|
- self.unstage # unstage all devices that have been staged before
|
||||||
|
- self.cleanup # send a close scan message and perform additional cleanups if needed
|
||||||
|
"""
|
||||||
|
|
||||||
|
# import time
|
||||||
|
|
||||||
|
# import numpy as np
|
||||||
|
|
||||||
|
# from bec_lib.endpoints import MessageEndpoints
|
||||||
|
# from bec_lib.logger import bec_logger
|
||||||
|
# from bec_lib import messages
|
||||||
|
# from bec_server.scan_server.errors import ScanAbortion
|
||||||
|
# from bec_server.scan_server.scans import FlyScanBase, RequestBase, ScanArgType, ScanBase
|
||||||
|
|
||||||
|
# logger = bec_logger.logger
|
0
phoenix_bec/services/__init__.py
Normal file
0
phoenix_bec/services/__init__.py
Normal file
74
pyproject.toml
Normal file
74
pyproject.toml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "phoenix_bec"
|
||||||
|
version = "0.0.0"
|
||||||
|
description = "Custom device implementations based on the ophyd hardware abstraction layer"
|
||||||
|
requires-python = ">=3.10"
|
||||||
|
classifiers = [
|
||||||
|
"Development Status :: 3 - Alpha",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Topic :: Scientific/Engineering",
|
||||||
|
]
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = [
|
||||||
|
"black",
|
||||||
|
"isort",
|
||||||
|
"coverage",
|
||||||
|
"pylint",
|
||||||
|
"pytest",
|
||||||
|
"pytest-random-order",
|
||||||
|
"ophyd_devices",
|
||||||
|
"bec_server",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.entry-points."bec"]
|
||||||
|
plugin_bec = "phoenix_bec"
|
||||||
|
|
||||||
|
[project.entry-points."bec.deployment.device_server"]
|
||||||
|
plugin_ds_startup = "phoenix_bec.deployments.device_server.startup:run"
|
||||||
|
|
||||||
|
[project.entry-points."bec.file_writer"]
|
||||||
|
plugin_file_writer = "phoenix_bec.file_writer"
|
||||||
|
|
||||||
|
[project.entry-points."bec.scans"]
|
||||||
|
plugin_scans = "phoenix_bec.scans"
|
||||||
|
|
||||||
|
[project.entry-points."bec.ipython_client_startup"]
|
||||||
|
plugin_ipython_client_pre = "phoenix_bec.bec_ipython_client.startup.pre_startup"
|
||||||
|
plugin_ipython_client_post = "phoenix_bec.bec_ipython_client.startup"
|
||||||
|
|
||||||
|
[project.entry-points."bec.widgets.auto_updates"]
|
||||||
|
plugin_widgets_update = "phoenix_bec.bec_widgets.auto_updates:PlotUpdate"
|
||||||
|
|
||||||
|
[project.entry-points."bec.widgets.user_widgets"]
|
||||||
|
plugin_widgets = "phoenix_bec.bec_widgets.widgets"
|
||||||
|
|
||||||
|
[tool.hatch.build.targets.wheel]
|
||||||
|
include = ["*"]
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
line_length = 100
|
||||||
|
multi_line_output = 3
|
||||||
|
include_trailing_comma = true
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
line-length = 100
|
||||||
|
skip-magic-trailing-comma = true
|
||||||
|
|
||||||
|
[tool.pylint.basic]
|
||||||
|
# Good variable names regexes, separated by a comma. If names match any regex,
|
||||||
|
# they will always be accepted
|
||||||
|
good-names-rgxs = [
|
||||||
|
".*scanID.*",
|
||||||
|
".*RID.*",
|
||||||
|
".*pointID.*",
|
||||||
|
".*ID.*",
|
||||||
|
".*_2D.*",
|
||||||
|
".*_1D.*",
|
||||||
|
]
|
31
tests/tests_bec_ipython_client/README.md
Normal file
31
tests/tests_bec_ipython_client/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Getting Started with Testing using pytest
|
||||||
|
|
||||||
|
BEC is using the [pytest](https://docs.pytest.org/en/8.0.x/) framework.
|
||||||
|
It can be install via
|
||||||
|
``` bash
|
||||||
|
pip install pytest
|
||||||
|
```
|
||||||
|
in your *python environment*.
|
||||||
|
We note that pytest is part of the optional-dependencies `[dev]` of the plugin package.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Tests in this package should be stored in the `tests` directory.
|
||||||
|
We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of `<test_module_name.py>`.
|
||||||
|
|
||||||
|
To run all tests, navigate to the directory of the plugin from the command line, and run the command
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pytest -v --random-order ./tests
|
||||||
|
```
|
||||||
|
Note, the python environment needs to be active.
|
||||||
|
The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run.
|
||||||
|
The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines.
|
||||||
|
|
||||||
|
## Test examples
|
||||||
|
|
||||||
|
Writing tests can be quite specific for the given function.
|
||||||
|
We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes.
|
||||||
|
A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html).
|
||||||
|
In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html).
|
||||||
|
|
31
tests/tests_bec_widgets/README.md
Normal file
31
tests/tests_bec_widgets/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Getting Started with Testing using pytest
|
||||||
|
|
||||||
|
BEC is using the [pytest](https://docs.pytest.org/en/8.0.x/) framework.
|
||||||
|
It can be install via
|
||||||
|
``` bash
|
||||||
|
pip install pytest
|
||||||
|
```
|
||||||
|
in your *python environment*.
|
||||||
|
We note that pytest is part of the optional-dependencies `[dev]` of the plugin package.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Tests in this package should be stored in the `tests` directory.
|
||||||
|
We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of `<test_module_name.py>`.
|
||||||
|
|
||||||
|
To run all tests, navigate to the directory of the plugin from the command line, and run the command
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pytest -v --random-order ./tests
|
||||||
|
```
|
||||||
|
Note, the python environment needs to be active.
|
||||||
|
The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run.
|
||||||
|
The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines.
|
||||||
|
|
||||||
|
## Test examples
|
||||||
|
|
||||||
|
Writing tests can be quite specific for the given function.
|
||||||
|
We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes.
|
||||||
|
A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html).
|
||||||
|
In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html).
|
||||||
|
|
31
tests/tests_dap_services/README.md
Normal file
31
tests/tests_dap_services/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Getting Started with Testing using pytest
|
||||||
|
|
||||||
|
BEC is using the [pytest](https://docs.pytest.org/en/8.0.x/) framework.
|
||||||
|
It can be install via
|
||||||
|
``` bash
|
||||||
|
pip install pytest
|
||||||
|
```
|
||||||
|
in your *python environment*.
|
||||||
|
We note that pytest is part of the optional-dependencies `[dev]` of the plugin package.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Tests in this package should be stored in the `tests` directory.
|
||||||
|
We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of `<test_module_name.py>`.
|
||||||
|
|
||||||
|
To run all tests, navigate to the directory of the plugin from the command line, and run the command
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pytest -v --random-order ./tests
|
||||||
|
```
|
||||||
|
Note, the python environment needs to be active.
|
||||||
|
The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run.
|
||||||
|
The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines.
|
||||||
|
|
||||||
|
## Test examples
|
||||||
|
|
||||||
|
Writing tests can be quite specific for the given function.
|
||||||
|
We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes.
|
||||||
|
A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html).
|
||||||
|
In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html).
|
||||||
|
|
31
tests/tests_devices/README.md
Normal file
31
tests/tests_devices/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Getting Started with Testing using pytest
|
||||||
|
|
||||||
|
BEC is using the [pytest](https://docs.pytest.org/en/8.0.x/) framework.
|
||||||
|
It can be install via
|
||||||
|
``` bash
|
||||||
|
pip install pytest
|
||||||
|
```
|
||||||
|
in your *python environment*.
|
||||||
|
We note that pytest is part of the optional-dependencies `[dev]` of the plugin package.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Tests in this package should be stored in the `tests` directory.
|
||||||
|
We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of `<test_module_name.py>`.
|
||||||
|
|
||||||
|
To run all tests, navigate to the directory of the plugin from the command line, and run the command
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pytest -v --random-order ./tests
|
||||||
|
```
|
||||||
|
Note, the python environment needs to be active.
|
||||||
|
The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run.
|
||||||
|
The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines.
|
||||||
|
|
||||||
|
## Test examples
|
||||||
|
|
||||||
|
Writing tests can be quite specific for the given function.
|
||||||
|
We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes.
|
||||||
|
A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html).
|
||||||
|
In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html).
|
||||||
|
|
31
tests/tests_file_writer/README.md
Normal file
31
tests/tests_file_writer/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Getting Started with Testing using pytest
|
||||||
|
|
||||||
|
BEC is using the [pytest](https://docs.pytest.org/en/8.0.x/) framework.
|
||||||
|
It can be install via
|
||||||
|
``` bash
|
||||||
|
pip install pytest
|
||||||
|
```
|
||||||
|
in your *python environment*.
|
||||||
|
We note that pytest is part of the optional-dependencies `[dev]` of the plugin package.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Tests in this package should be stored in the `tests` directory.
|
||||||
|
We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of `<test_module_name.py>`.
|
||||||
|
|
||||||
|
To run all tests, navigate to the directory of the plugin from the command line, and run the command
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pytest -v --random-order ./tests
|
||||||
|
```
|
||||||
|
Note, the python environment needs to be active.
|
||||||
|
The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run.
|
||||||
|
The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines.
|
||||||
|
|
||||||
|
## Test examples
|
||||||
|
|
||||||
|
Writing tests can be quite specific for the given function.
|
||||||
|
We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes.
|
||||||
|
A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html).
|
||||||
|
In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html).
|
||||||
|
|
31
tests/tests_scans/README.md
Normal file
31
tests/tests_scans/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Getting Started with Testing using pytest
|
||||||
|
|
||||||
|
BEC is using the [pytest](https://docs.pytest.org/en/8.0.x/) framework.
|
||||||
|
It can be install via
|
||||||
|
``` bash
|
||||||
|
pip install pytest
|
||||||
|
```
|
||||||
|
in your *python environment*.
|
||||||
|
We note that pytest is part of the optional-dependencies `[dev]` of the plugin package.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Tests in this package should be stored in the `tests` directory.
|
||||||
|
We suggest to sort tests of different submodules, i.e. `scans` or `devices` in the respective folder structure, and to folow a naming convention of `<test_module_name.py>`.
|
||||||
|
|
||||||
|
To run all tests, navigate to the directory of the plugin from the command line, and run the command
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pytest -v --random-order ./tests
|
||||||
|
```
|
||||||
|
Note, the python environment needs to be active.
|
||||||
|
The additional arg `-v` allows pytest to run in verbose mode which provides more detailed information about the tests being run.
|
||||||
|
The argument `--random-order` instructs pytest to run the tests in random order, which is the default in the CI pipelines.
|
||||||
|
|
||||||
|
## Test examples
|
||||||
|
|
||||||
|
Writing tests can be quite specific for the given function.
|
||||||
|
We recommend writing tests as isolated as possible, i.e. try to test single functions instead of full classes.
|
||||||
|
A very useful class to enable isolated testing is [MagicMock](https://docs.python.org/3/library/unittest.mock.html).
|
||||||
|
In addition, we also recommend to take a look at the [How-to guides from pytest](https://docs.pytest.org/en/8.0.x/how-to/index.html).
|
||||||
|
|
Reference in New Issue
Block a user