Skip to content

Commit cabab34

Browse files
authored
Merge pull request #3 from ddasilva/unit-tests
Fix Unit Tests and Add Github Actions
2 parents 33b7cb1 + 38ddaa5 commit cabab34

11 files changed

+80
-22
lines changed

.github/workflows/unit-tests.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test Suncet Data Processing Pipeline
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
# python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"]
11+
python-version: ["3.9", "3.10"]
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
# Install dependencies
20+
- name: Install requiremetns
21+
run: pip install -r requirements.txt
22+
# Run unit tests
23+
- name: Run Unit Tests
24+
run: pytest -v

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SunCET Data Processing Pipeline
55

66
## Instructions
7-
The SunCET Data Processing Pipeline is written in Python. To use the software, the first step is to clone the repository and install the dependencies. The dependencies may be installed through one of two routes. First, one may use the `environment.yml` file with [Anaconda](https://www.anaconda.com/) or a compatible replacement (such as [Miniconda](https://docs.anaconda.com/miniconda/), [Mamba](https://mamba.readthedocs.io/en/latest/) or [Micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)). The `environment.yml` route only uses the free channels (conda-forge), which do not require a paid account. Alternatively, one can use the `requirements.txt` file directly with `pip`.
7+
The SunCET Data Processing Pipeline is written in Python. To use the software, the first step is to clone the repository and install the dependencies. The dependencies may be installed through one of two routes. First, one may use the `environment.yml` file with [Anaconda](https://www.anaconda.com/) or a compatible replacement (such as [Miniconda](https://docs.anaconda.com/miniconda/), [Mamba](https://mamba.readthedocs.io/en/latest/) or [Micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)). The `environment.yml` route only uses the free channels (conda-forge), which do not require a paid account. Alternatively, one can use the `requirements.txt` file directly with `pip` (Python 3.9 and 3.10 only).
88

99
To use the `environment.yml` route, run the following line. The `conda` command can be replaced with `mamba` or `micromamba` as needed.
1010

@@ -37,6 +37,13 @@ To delete a run from disk, all thats needed is to delete its directory:
3737
$ rm -r processing_runs/MYRUN`
3838
```
3939

40+
## Running the tests
41+
To run the tests, run the following command from the top-level directory:
42+
43+
```
44+
$ pytest -v
45+
```
46+
4047
## Discussion: Input
4148
* To get to Level 0b: Raw binary files downlinked from the spacecraft
4249
* To get to Level 0c, 1, and 2: the output of the preceding level

environment.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ channels:
66
dependencies:
77
- pip >=22.1
88
- python=3.10
9-
- pytest=7.1
109
- pytest-cov=3.0
1110
- numpy=1.22
1211
- matplotlib=3.5
@@ -21,5 +20,5 @@ dependencies:
2120
- gnuradio=3.10.5.1
2221
- gnuradio-satellites=5.2.0
2322
- termcolor==2.4.0
24-
23+
- pytest==7.1.3
2524
#prefix: ~/anaconda3

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
numpy==1.22
22
matplotlib==3.5
3-
pytest==7.1
43
pytest-cov==3.0
54
jupyter==1.0
65
scipy==1.8.1
@@ -12,3 +11,4 @@ netCDF4==1.6.0
1211
h5netcdf==1.1.0
1312
bottleneck==1.3.7
1413
termcolor==2.4.0
14+
pytest==7.1.3

suncet_processing_pipeline/tests/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
from .. import config_parser
4+
5+
6+
def test_read_default_config():
7+
default_config = os.path.join(
8+
os.path.dirname(__file__), '..', 'config_files',
9+
'config_default.ini'
10+
)
11+
config = config_parser.Config(default_config)
12+
13+
assert hasattr(config, 'make_level0_5')
14+
assert hasattr(config, 'make_level1')
15+
assert hasattr(config, 'make_level2')
16+
assert hasattr(config, 'make_level3')
17+
assert hasattr(config, 'make_level4')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
from .. import config_parser, make_level1
3+
4+
5+
def test_Level1_object_instantiates():
6+
default_config = os.path.join(
7+
os.path.dirname(__file__), '..', 'config_files',
8+
'config_default.ini'
9+
)
10+
config = config_parser.Config(default_config)
11+
make_level1.Level1(config)
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import os
2+
from .. import config_parser, make_level2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
from .. import config_parser, make_level3
3+
4+
5+
def test_Level3_object_instantiates():
6+
default_config = os.path.join(
7+
os.path.dirname(__file__), '..', 'config_files',
8+
'config_default.ini'
9+
)
10+
config = config_parser.Config(default_config)
11+
make_level3.Level3(config)
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
from .. import config_parser, make_level1
3+

tests/test_example.py

-18
This file was deleted.

0 commit comments

Comments
 (0)