Skip to content

Commit 05d845e

Browse files
author
Alan Christie
committed
fix: decoder now requires collection
1 parent 5343fd9 commit 05d845e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

decoder/decoder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,15 @@ def validate_job_schema(job_definition: Dict[str, Any]) -> Optional[str]:
8181
return None
8282

8383

84-
def get_job_doc_url(job: str, job_definition: Dict[str, Any], manifest_url: str) -> str:
84+
def get_job_doc_url(
85+
collection: str, job: str, job_definition: Dict[str, Any], manifest_url: str
86+
) -> str:
8587
"""Returns the Job's documentation URL for a specific Job using the JOb's
8688
'doc-url' and manifest URL. The job manifest is expected to
8789
have been validated, and we expect to have been given one job structure
8890
from the job's definition, not the whole job definition file.
8991
"""
92+
assert collection
9093
assert job
9194
assert isinstance(job_definition, dict)
9295
assert manifest_url
@@ -109,7 +112,6 @@ def get_job_doc_url(job: str, job_definition: Dict[str, Any], manifest_url: str)
109112
# https://raw.githubusercontent.com/InformaticsMatters/
110113
# virtual-screening/main/data-manager/docs
111114

112-
collection: str = job_definition["collection"]
113115
doc_url: Optional[str] = job_definition.get("doc-url", None)
114116

115117
# If doc-url starts 'https://' just return it

tests/test_get_job_doc_url.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
def test_get_job_doc_url_with_fq_doc_url():
1212
# Arrange
13+
collection: str = "collection-x"
1314
job: str = "job-x"
1415
job_definition: Dict = {
15-
"collection": "collection-x",
1616
"doc-url": "https://example.com/docs/doc.md",
1717
}
1818
manifest_url: str = (
@@ -23,7 +23,7 @@ def test_get_job_doc_url_with_fq_doc_url():
2323
expected_doc_url: str = "https://example.com/docs/doc.md"
2424

2525
# Act
26-
doc_url = decoder.get_job_doc_url(job, job_definition, manifest_url)
26+
doc_url = decoder.get_job_doc_url(collection, job, job_definition, manifest_url)
2727

2828
# Assert
2929
assert doc_url
@@ -32,8 +32,9 @@ def test_get_job_doc_url_with_fq_doc_url():
3232

3333
def test_get_job_doc_url_with_partial_doc_url():
3434
# Arrange
35+
collection: str = "collection-x"
3536
job: str = "job-x"
36-
job_definition: Dict = {"collection": "collection-x", "doc-url": "special/doc.md"}
37+
job_definition: Dict = {"doc-url": "special/doc.md"}
3738
manifest_url: str = (
3839
"https://raw.githubusercontent.com/"
3940
"InformaticsMatters/virtual-screening/main/data-manager/"
@@ -46,7 +47,7 @@ def test_get_job_doc_url_with_partial_doc_url():
4647
)
4748

4849
# Act
49-
doc_url = decoder.get_job_doc_url(job, job_definition, manifest_url)
50+
doc_url = decoder.get_job_doc_url(collection, job, job_definition, manifest_url)
5051

5152
# Assert
5253
assert doc_url
@@ -55,8 +56,9 @@ def test_get_job_doc_url_with_partial_doc_url():
5556

5657
def test_get_job_doc_url_with_no_doc_url():
5758
# Arrange
59+
collection: str = "collection-x"
5860
job: str = "job-x"
59-
job_definition: Dict = {"collection": "collection-x"}
61+
job_definition: Dict = {}
6062
manifest_url: str = (
6163
"https://raw.githubusercontent.com/"
6264
"InformaticsMatters/virtual-screening/main/data-manager/"
@@ -69,7 +71,7 @@ def test_get_job_doc_url_with_no_doc_url():
6971
)
7072

7173
# Act
72-
doc_url = decoder.get_job_doc_url(job, job_definition, manifest_url)
74+
doc_url = decoder.get_job_doc_url(collection, job, job_definition, manifest_url)
7375

7476
# Assert
7577
assert doc_url

0 commit comments

Comments
 (0)