Skip to content
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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,16 @@ jobs:

- name: Run tests
run: cargo test --features serde,pyo3 --release

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: "stable"

- name: Check formatting of Rust code with rustfmt
uses: actions-rust-lang/rustfmt@v1.1.1
3 changes: 1 addition & 2 deletions src/term_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ mod serde {
}
}


/// The representation of the prefix of a [`TermId`].
///
/// ### Examples
Expand Down Expand Up @@ -539,7 +538,7 @@ impl TryFrom<&str> for KnownPrefix {
Ok(KnownPrefix::PMID)
} else if value.starts_with("UO") {
Ok(KnownPrefix::UO)
}else {
} else {
Err(())
}
}
Expand Down
4 changes: 1 addition & 3 deletions tests/test_common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ontolius::common::{hpo, go, maxo, uo};
use ontolius::common::{go, hpo, maxo, uo};

#[test]
fn hpo_commons_are_accessible() {
Expand All @@ -23,5 +23,3 @@ fn maxo_commons_are_accessible() {
fn uo_commons_are_accessible() {
assert_eq!(uo::UNIT, ("UO", "0000000"))
}


16 changes: 11 additions & 5 deletions tests/test_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ mod medical_action_ontology {
}
}


/// Unit of Measurement Ontology (UO) tests.
mod unit_measurement_ontology {

Expand All @@ -390,7 +389,9 @@ mod unit_measurement_ontology {
File::open(UO_PATH).expect("Obographs JSON file should exist"),
));
let loader = OntologyLoaderBuilder::new().obographs_parser().build();
loader.load_from_read(reader).expect("Obographs JSON should be well formatted")
loader
.load_from_read(reader)
.expect("Obographs JSON should be well formatted")
})
}

Expand Down Expand Up @@ -419,7 +420,12 @@ mod unit_measurement_ontology {
test_ancestors!(
uo,
"UO:0010002", // millisiemens
&["conduction unit", "electrical conduction unit", "siemens based unit", "unit"]
&[
"conduction unit",
"electrical conduction unit",
"siemens based unit",
"unit"
]
);
test_ancestors!(
uo,
Expand All @@ -440,6 +446,6 @@ mod unit_measurement_ontology {
fn version_parsing() {
let uo = uo();

assert_eq!(uo.version(), "2026-01-09") ;
assert_eq!(uo.version(), "2026-01-09");
}
}
}
8 changes: 4 additions & 4 deletions tests/test_serde.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/// An example of serializing a TermId as a CURIE.
///
///
/// When working with types that use [`ontolius::TermId`]s and their serialization,
/// we would like to derive both [`serde::Serialize`] and [`serde::Deserialize`] traits
/// to enable interoperability with the `serde` crate.
/// However, we cannot do this directly since [`ontolius::TermId`] does not implement the traits.
///
///
/// As a workaround, `serde`` allows using custom serialization and deserialization functions
/// and `ontolius` provides functions to use with (de)serialization.
///
///
/// The functions are available on [`ontolius::TermId`] when the `serde` feature is enabled.
/// An example usage is shown in this module.
#[cfg(feature = "serde")]
Expand All @@ -19,7 +19,7 @@ mod test_serde {
use ontolius::TermId;

/// An example struct that we want to serialize and deserialize with serde.
///
///
/// Use the `serde` attributes on the `term_id` field
/// to serialize the `TermId` as CURIE.
#[derive(PartialEq, Debug, serde::Serialize, serde::Deserialize)]
Expand Down