diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..2cd1d4d --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,29 @@ +name: Code testing + +on: [push, pull_request] + +jobs: + Tests: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + + # run the tests located in skrf/ + - name: Test the code, tutorials and examples + if: ${{ always() }} + run: | + tox diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e2c2d6e --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +# running 'tox' will run the tests located in west_ic_antenna/ +# running 'tox -- --nbval-lax' will also run all the notebooks located in doc/ +[tox] +isolated_build = True +envlist = py{37, 38, 39, 310, 311, 312} + +[gh-actions] +python = + 3.7: py37 + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 + +# This is the default testsetup with all dependencies installed +[testenv] +deps = + pytest +commands = + python -m pytest + \ No newline at end of file diff --git a/west_ic_antenna/test/test_antenna.py b/west_ic_antenna/test/test_antenna.py new file mode 100644 index 0000000..aca7709 --- /dev/null +++ b/west_ic_antenna/test/test_antenna.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +import pytest +import skrf as rf +import os + +from west_ic_antenna.antenna import ( + WestIcrhAntenna, + DEFAULT_FRONT_FACE, + S_PARAMS_DIR, + DEFAULT_BRIDGE, + DEFAULT_IMPEDANCE_TRANSFORMER, + DEFAULT_SERVICE_STUB, +) + +# Useful definitions +TEST_DIR = os.path.dirname(os.path.abspath(__file__)) +DATA_DIR = os.path.join(TEST_DIR, '../data') + +@pytest.fixture +def antenna_default_arg(): + return WestIcrhAntenna() + +# Constructor Tests +def test_constructor_default(antenna_default_arg): + """Test creation of Antenna instance""" + assert isinstance(antenna_default_arg, WestIcrhAntenna) + +def test_setup_constructor_frequency(): + freq = rf.Frequency(30, 60, npoints=10, unit='MHz') + _ant = WestIcrhAntenna(frequency=freq) + assert isinstance(_ant, WestIcrhAntenna) + +def test_setup_constructor_capa(): + Cs = [20, 30, 40, 50] + _ant = WestIcrhAntenna(Cs=Cs) + assert isinstance(_ant, WestIcrhAntenna) + +def test_setup_constructor_frontface_filename(): + _ant = WestIcrhAntenna(front_face=DEFAULT_FRONT_FACE) + assert isinstance(_ant, WestIcrhAntenna) + +def test_setup_constructor_frontface_network(): + ntw = rf.Network(DEFAULT_FRONT_FACE) + _ant = WestIcrhAntenna(front_face=ntw) + assert isinstance(_ant, WestIcrhAntenna) +