-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to get model name (#150)
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 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
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 @@ | ||
"""Utility functions for AirGradient.""" | ||
|
||
from __future__ import annotations | ||
|
||
|
||
def get_model_name(model_id: str) -> str | None: | ||
"""Get model name from identifier.""" | ||
if model_id.startswith("I-9PSL"): | ||
return "AirGradient ONE" | ||
if model_id.startswith("O-1PPT"): | ||
return "AirGradient Open Air" | ||
if "DIY" in model_id: | ||
return "AirGradient DIY" | ||
return None |
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,24 @@ | ||
"""Tests for the util module.""" | ||
|
||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from airgradient import get_model_name | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("model_id", "model_name"), | ||
[ | ||
("I-9PSL", "AirGradient ONE"), | ||
("I-9PSL-DE", "AirGradient ONE"), | ||
("O-1PPT", "AirGradient Open Air"), | ||
("DIY-PRO-4.3", "AirGradient DIY"), | ||
("DIY-PRO-3.7", "AirGradient DIY"), | ||
("DIY-BASIC-4.0", "AirGradient DIY"), | ||
("ABC", None), | ||
], | ||
) | ||
def test_get_model_name(model_id: str, model_name: str | None) -> None: | ||
"""Test get_model_name.""" | ||
assert get_model_name(model_id) == model_name |