Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ jobs:
uses: ./.github/workflows/code_quality.yml
secrets: inherit

# # Tests of isolated source code
# unit_tests:
# needs: quality_tests
# Tests of isolated source code
unit_tests:
needs: quality_tests
uses: ./.github/workflows/unit_test.yml
secrets: inherit

# # Collects code from repository and constructs compiled project
# build:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow runs unit-tests from the given directory
name: Unit tests

# This workflow is callable from other workflows
on:
workflow_call:

jobs:
unit-test:
name: Unit Tests
runs-on: ubuntu-latest
with:
ENVIRONMENT: Production
steps:
- name: Extract branch name
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Checkout repository code
uses: actions/checkout@v4
with:
ref: ${{ steps.extract_branch.outputs.branch }}

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Setup Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: 2.0.1

- name: Install dependencies
run: poetry install

- name: Print context
run: echo "$GITHUB_CONTEXT"

- name: Run unit tests
run: python tests/unit_tests.py
19 changes: 19 additions & 0 deletions tests/unit_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import datetime

from frcm.frcapi import METFireRiskAPI
from frcm.datamodel.model import Location

frc = METFireRiskAPI()

location = Location(latitude=60.383, longitude=5.3327) # Bergen
# location = Location(latitude=59.4225, longitude=5.2480) # Haugesund

# days into the past to retrieve observed weather data
obs_delta = datetime.timedelta(days=2)

wd = frc.get_weatherdata_now(location, obs_delta)
print(wd)

predictions = frc.compute_now(location, obs_delta)

print(predictions)