forked from pytroll/pytroll-active-fire-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pytroll#4 from adybbroe/add-unittests
Added first very small unittest
- Loading branch information
Showing
10 changed files
with
225 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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,14 @@ | ||
[run] | ||
branch = True | ||
source = pytroll-active-fire-runner | ||
relative_files = True | ||
|
||
[report] | ||
exclude_lines = | ||
if self.debug: | ||
pragma: no cover | ||
raise NotImplementedError | ||
if __name__ == .__main__.: | ||
ignore_errors = True | ||
omit = | ||
tests/* |
This file contains 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,19 @@ | ||
#### Code Sample, a minimal, complete, and verifiable piece of code | ||
|
||
```python | ||
# Your code here | ||
|
||
``` | ||
#### Problem description | ||
|
||
[this should also explain **why** the current behaviour is a problem and why the | ||
expected output is a better solution.] | ||
|
||
#### Expected Output | ||
|
||
#### Actual Result, Traceback if applicable | ||
|
||
#### Versions of Python, package at hand and relevant dependencies | ||
|
||
|
||
Thank you for reporting an issue ! |
This file contains 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,7 @@ | ||
<!-- Describe what your PR does, and why --> | ||
|
||
- [ ] Closes #xxxx <!-- remove if there is no corresponding issue, which should only be the case for minor changes --> | ||
- [ ] Tests added <!-- for all bug fixes or enhancements --> | ||
- [ ] Tests passed: Passes ``pytest pyspectral`` <!-- for all non-documentation changes) --> | ||
- [ ] Passes ``flake8`` <!-- remove if you did not edit any Python files --> | ||
- [ ] Fully documented <!-- remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later --> |
This file contains 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,81 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
continue-on-error: ${{ matrix.experimental }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: ["ubuntu-latest", "macos-latest"] | ||
python-version: ["3.8", "3.9"] | ||
experimental: [false] | ||
include: | ||
- python-version: "3.9" | ||
os: "ubuntu-latest" | ||
experimental: true | ||
|
||
env: | ||
PYTHON_VERSION: ${{ matrix.python-version }} | ||
OS: ${{ matrix.os }} | ||
UNSTABLE: ${{ matrix.experimental }} | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
|
||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Conda Environment | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ matrix.python-version }} | ||
mamba-version: "*" | ||
channels: conda-forge,defaults | ||
environment-file: continuous_integration/environment.yaml | ||
activate-environment: test-environment | ||
|
||
- name: Install unstable dependencies | ||
if: matrix.experimental == true | ||
shell: bash -l {0} | ||
run: | | ||
python -m pip install \ | ||
--no-deps --upgrade \ | ||
git+https://github.com/pytroll/posttroll \ | ||
git+https://github.com/pytroll/trollsift; | ||
- name: Install pytroll-active-fire-runner | ||
shell: bash -l {0} | ||
run: | | ||
pip install --no-deps -e . | ||
- name: Run unit tests | ||
shell: bash -l {0} | ||
run: | | ||
pytest --cov=viirs_active_fires viirs_active_fires/tests --cov-report=xml --cov-report= | ||
- name: Upload unittest coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
flags: unittests | ||
file: ./coverage.xml | ||
env_vars: OS,PYTHON_VERSION,UNSTABLE | ||
fail_ci_if_error: false | ||
|
||
- name: Coveralls Parallel | ||
uses: AndreMiras/coveralls-python-action@develop | ||
with: | ||
flag-name: run-${{ matrix.test_number }} | ||
parallel: true | ||
if: runner.os == 'Linux' | ||
|
||
coveralls: | ||
needs: [test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Coveralls Finished | ||
uses: AndreMiras/coveralls-python-action@develop | ||
with: | ||
parallel-finished: true |
This file contains 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,25 @@ | ||
name: Deploy sdist | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v2 | ||
|
||
- name: Create sdist | ||
shell: bash -l {0} | ||
run: python setup.py sdist | ||
|
||
- name: Publish package to PyPI | ||
if: github.event.action == 'published' | ||
uses: pypa/gh-action-pypi-publish@v1.4.1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |
This file contains 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,2 +1,8 @@ | ||
# pytroll-active-fire-runner | ||
pytroll-active-fire-runner | ||
========================== | ||
|
||
[![Build status](https://github.com/pytroll/pytroll-active-fire-runner/workflows/CI/badge.svg?branch=main)](https://github.com/pytroll/pytroll-active-fire-runner/workflows/CI/badge.svg?branch=main) | ||
[![Coverage Status](https://coveralls.io/repos/github/pytroll/pytroll-active-fire-runner/badge.svg)](https://coveralls.io/github/pytroll/pytroll-active-fire-runner) | ||
|
||
|
||
Using 3rd party software like CSPP to generate active fire products |
This file contains 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 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,20 @@ | ||
name: test-environment | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- distributed | ||
- toolz | ||
- sphinx | ||
- pyyaml | ||
- pyproj | ||
- coveralls | ||
- coverage | ||
- codecov | ||
- behave | ||
- mock | ||
- pytest | ||
- pytest-cov | ||
- pip | ||
- pip: | ||
- trollsift | ||
- posttroll |
This file contains 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,45 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright (c) 2021 Adam.Dybbroe | ||
|
||
# Author(s): | ||
|
||
# Adam.Dybbroe <a000680@c21856.ad.smhi.se> | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Unit testing the utility functions. | ||
""" | ||
|
||
import os.path | ||
import pytest | ||
from datetime import datetime | ||
from unittest.mock import patch | ||
|
||
from viirs_active_fires.utils import get_edr_times | ||
|
||
TESTFILENAME = "AFIMG_npp_d20210413_t0916186_e0917428_b49018_c20210413092919781783_cspp_dev.txt" | ||
|
||
|
||
@patch('os.path.basename') | ||
def test_get_edr_times(basename): | ||
"""Test getting the start and end times from the edr filename.""" | ||
|
||
basename.return_value = TESTFILENAME | ||
timetup = get_edr_times('myfilename') | ||
|
||
expected = (datetime(2021, 4, 13, 9, 16, 18), datetime(2021, 4, 13, 9, 17, 42)) | ||
assert timetup[0] == expected[0] | ||
assert timetup[1] == expected[1] |
This file contains 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