-
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.
adding unittest-style tests, bumping version
- Loading branch information
Showing
9 changed files
with
153 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.0.1' | ||
__version__ = '0.1.0' |
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
Empty file.
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,43 @@ | ||
""" Methods for test cases involving checking Docker images | ||
:Author: Jonathan Karr <[email protected]> | ||
:Date: 2020-12-21 | ||
:Copyright: 2020, Center for Reproducible Biomedical Modeling | ||
:License: MIT | ||
""" | ||
|
||
from ..data_model import AbstractTestCase | ||
import docker | ||
import warnings | ||
|
||
|
||
class OciLabelsCase(AbstractTestCase): | ||
""" Test that a Docker image has Open Container Initiative (OCI) labels with metadata about image """ | ||
EXPECTED_LABELS = [ | ||
'org.opencontainers.image.authors', | ||
'org.opencontainers.image.description', | ||
'org.opencontainers.image.documentation', | ||
'org.opencontainers.image.licenses', | ||
'org.opencontainers.image.revision', | ||
'org.opencontainers.image.source', | ||
'org.opencontainers.image.title', | ||
'org.opencontainers.image.url', | ||
'org.opencontainers.image.vendor', | ||
'org.opencontainers.image.version', | ||
] | ||
|
||
def eval(self, specifications): | ||
""" Evaluate a simulator's performance on a test case | ||
Args: | ||
specifications (:obj:`dict`): specifications of the simulator to validate | ||
Raises: | ||
:obj:`Exception`: if the simulator did not pass the test case | ||
""" | ||
docker_client = docker.from_env() | ||
image = docker_client.images.pull(specifications['image']['url']) | ||
missing_labels = set(self.EXPECTED_LABELS).difference(set(image.labels.keys())) | ||
if missing_labels: | ||
warnings.warn('The Docker image should have the following Open Container Initiative (OCI) labels:\n {}'.format( | ||
'\n '.join(sorted(missing_labels)))) |
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,4 +1,5 @@ | ||
biosimulators_utils[docker] >= 0.1.19 | ||
capturer | ||
cement | ||
docker | ||
natsort |
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,10 @@ | ||
from biosimulators_test_suite.test_case import docker_image | ||
import unittest | ||
|
||
|
||
class DockerImageTestCaseTest(unittest.TestCase): | ||
def test_OciLabelsCase(self): | ||
case = docker_image.OciLabelsCase() | ||
case.eval({'image': {'url': 'ghcr.io/biosimulators/biosimulators_copasi/copasi:latest'}}) | ||
with self.assertWarnsRegex(UserWarning, 'should have the following'): | ||
case.eval({'image': {'url': 'hello-world'}}) |