Skip to content

Commit c340abf

Browse files
committed
Implement a simple test
1 parent b4bbe04 commit c340abf

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

.github/workflows/python.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ jobs:
2323
- name: Install plasma source
2424
run: |
2525
git submodule update --init --recursive
26-
pip install wheel
26+
pip install -r requirements-develop.txt
2727
python setup.py bdist_wheel
2828
python -m pip install --verbose dist/*.whl
29+
- name: run tests
30+
run: |
31+
pytest tests
2932
- name: upload wheel
3033
uses: actions/upload-artifact@v2
3134
with:

requirements-develop.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
wheel

tests/test_plasma_source.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Tests for the methods in plasma_source."""
2+
3+
import pytest
4+
5+
from parametric_plasma_source.plasma_source import PlasmaSource
6+
7+
plasma_params = {
8+
"elongation": 1.557,
9+
"ion_density_origin": 1.09e20,
10+
"ion_density_peaking_factor": 1,
11+
"ion_density_pedistal": 1.09e20,
12+
"ion_density_seperatrix": 3e19,
13+
"ion_temperature_origin": 45.9,
14+
"ion_temperature_peaking_factor": 8.06,
15+
"ion_temperature_pedistal": 6.09,
16+
"ion_temperature_seperatrix": 0.1,
17+
"major_radius": 906.0,
18+
"minor_radius": 292.258,
19+
"pedistal_radius": 0.8 * 292.258,
20+
"plasma_id": 1,
21+
"shafranov_shift": 44.789,
22+
"triangularity": 0.270,
23+
"ion_temperature_beta": 6,
24+
}
25+
26+
27+
@pytest.fixture(scope="session")
28+
def plasma_source():
29+
"""Make a plasma source to use as a test fixture."""
30+
return PlasmaSource(**plasma_params)
31+
32+
33+
class TestPlasmaSource:
34+
"""A class to run tests against the plasma source."""
35+
36+
def test_ion_density_magnetic_origin(self, plasma_source):
37+
"""Test the ion density at the magnetic origin."""
38+
ion_density = plasma_source.ion_density(0.0)
39+
40+
assert pytest.approx(ion_density, 1.09e20)

0 commit comments

Comments
 (0)