-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use mock VERSION_PINS env variable for tests. Encasuplate version_pin…
… logic in function
- Loading branch information
Showing
2 changed files
with
50 additions
and
34 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 |
---|---|---|
@@ -1,23 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Tests for PyOBO VERSION_PINS.""" | ||
|
||
import os | ||
import unittest | ||
from unittest import mock | ||
|
||
from pyobo.api.utils import get_version | ||
from pyobo.constants import VERSION_PINS | ||
from pyobo.constants import get_version_pins | ||
|
||
MOCK_VERSION_PINS = '{"ncbitaxon": "2024-05-08", "vo":"2024-04-09", ' '"chebi":"235", "bfo":5}' | ||
|
||
|
||
@mock.patch.dict(os.environ, {"VERSION_PINS": MOCK_VERSION_PINS}) | ||
class TestVersionPins(unittest.TestCase): | ||
"""Test using VERSION_PINS.""" | ||
|
||
def test_correct_version_pin_types(self): | ||
"""Test resource and version type.""" | ||
for resource_prefix, version in VERSION_PINS.items(): | ||
version_pins = get_version_pins() | ||
for resource_prefix, version in version_pins.items(): | ||
self.assertIsInstance(resource_prefix, str) | ||
self.assertIsInstance(version, str) | ||
|
||
def test_use_correct_version_pin(self): | ||
"""Tests correct resource version is used.""" | ||
for resource_prefix, version in VERSION_PINS.items(): | ||
version_pins = get_version_pins() | ||
for resource_prefix, version in version_pins.items(): | ||
self.assertEqual(get_version(resource_prefix), version) |