Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD ci-cd config file #57

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
38 changes: 0 additions & 38 deletions .github/workflows/r-cicd.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/r-cmd-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: R-testthat

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: "4.1" # or any version you need

- name: Install dependencies
run: |
Rscript -e 'install.packages("devtools")'
Rscript -e 'devtools::install_deps(dependencies = TRUE)'

- name: Run testthat tests
run: |
Rscript -e 'library(testthat); test_dir("tests/testthat")'
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ This project is licensed under the MIT License - see the LICENSE file for detail
- The models presented are based on plant pathology research in the University of Madison Wisconsin, paper: [Nature Scientific Reports, 2023](https://www.nature.com/articles/s41598-023-44338-6)
- This software was created by the [Data Science Institute](https://datascience.wisc.edu) at the [University of Wisconsin-Madison](https://www.wisc.edu)

Mantainer: Maria Oros, [email protected]
Mantainer: Maria Oros, [email protected]


![R-CMD-check](https://github.com/mariaob1201/corn_disease_forecast_api/actions/workflows/r-cmd-check.yml/badge.svg)
31 changes: 0 additions & 31 deletions tests/testthat/test-calculate_non_irrigated_risk.R

This file was deleted.

24 changes: 24 additions & 0 deletions tests/testthat/test-logit_functions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
install.packages("testthat")

library(testthat)
library(here) # Use here for flexible paths if needed

source(here("R/logit_functions.R")) # Ensure this path correctly points to the functions you want to test

test_that("logistic function returns probabilities between 0 and 1", {
expect_true(all(logistic(c(-5, 0, 5)) >= 0 & logistic(c(-5, 0, 5)) <= 1))
})

test_that("calculate_disease_risk handles threshold values correctly", {
logit_values <- c(-1, 0, 1)
thresholds <- c(0.3, 0.7)
result <- calculate_disease_risk(logit_values, thresholds, "Test Disease")
expect_equal(result$disease, "Test Disease")
expect_true(result$probability >= 0 && result$probability <= 100)
})

test_that("classify_risk categorizes risk correctly", {
expect_equal(classify_risk(0.2, 0.3, 0.7), "Low")
expect_equal(classify_risk(0.5, 0.3, 0.7), "Medium")
expect_equal(classify_risk(0.8, 0.3, 0.7), "High")
})
Loading