generated from linkml/linkml-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from microbiomedata/issue-345-ial-solution
has credit association inlined as list
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
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,47 @@ | ||
import logging | ||
import traceback | ||
import unittest | ||
|
||
from linkml.validators.jsonschemavalidator import JsonSchemaDataValidator | ||
|
||
from python.nmdc import PersonValue, CreditAssociation, Study | ||
|
||
|
||
# from linkml_runtime.dumpers import yaml_dumper | ||
|
||
# todo reimplement with methods? | ||
|
||
|
||
class TestCA(unittest.TestCase): | ||
|
||
def test_sum(self): | ||
|
||
# nmdc_schema = "https://raw.githubusercontent.com/microbiomedata/nmdc-schema/main/src/schema/nmdc.yaml" | ||
nmdc_schema = "../src/schema/nmdc.yaml" | ||
|
||
validator = JsonSchemaDataValidator(nmdc_schema) | ||
|
||
pv1 = PersonValue(has_raw_value="GW Carver") | ||
pv2 = PersonValue(has_raw_value="L Pasteur") | ||
|
||
ca1 = CreditAssociation(applies_to_person=pv1, applied_roles=["Supervision", "Validation"]) | ||
ca2 = CreditAssociation(applies_to_person=pv2, applied_roles=["Investigation"]) | ||
|
||
s = Study(id="abc") | ||
|
||
# # why is schema loaded each time? | ||
validator.validate_object(ca1, target_class=CreditAssociation) | ||
validator.validate_object(ca2, target_class=CreditAssociation) | ||
|
||
try: | ||
s.has_credit_associations.append(ca1) | ||
s.has_credit_associations.append(ca2) | ||
validator.validate_object(s, target_class=Study) | ||
except Exception as e: | ||
logging.error(traceback.format_exc()) | ||
|
||
self.assertEqual(type(s), Study) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |