-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from cdisc-org/AddRulesEndpoints
Add rules endpoints
- Loading branch information
Showing
7 changed files
with
96 additions
and
2 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
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,15 @@ | ||
import os | ||
from cdisc_library_client import CDISCLibraryClient | ||
|
||
if __name__ == "__main__": | ||
api_key = os.environ.get("CDISC_LIBRARY_API_KEY") | ||
client = CDISCLibraryClient(api_key=api_key) | ||
|
||
catalogs = client.get_rule_catalogs() | ||
assert catalogs | ||
for catalog, link in catalogs.items(): | ||
href = link["href"] | ||
standard = href.split("/")[-2] | ||
version = href.split("/")[-1] | ||
rules = client.get_rules_catalog(standard, version) | ||
print(f"{catalog} has {len(rules.values())} rules") |
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,4 @@ | ||
__version__ = '0.1.3' | ||
__version__ = '0.1.4' | ||
|
||
import setuptools | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import imp | ||
from cdisc_library_client import CDISCLibraryClient | ||
from unittest import mock | ||
|
||
@mock.patch('cdisc_library_client.library_client.CDISCLibraryClient.get_api_json') | ||
def test_get_rule_catalogs(mock_get_api_json): | ||
client = CDISCLibraryClient(api_key="test") | ||
mock_response = { | ||
"_links": { | ||
"catalogs": { | ||
"sdtmig-3-4-cr": { | ||
"href": "/mdr/rules/sdtmig/3-4", | ||
"title": "sdtmig Conformance Rules v3-4", | ||
"type": "Conformance Rules Package" | ||
} | ||
}, | ||
"self": { | ||
"href": "/mdr/rules", | ||
"title": "CDISC Library Rules Catalog List", | ||
"type": "CDISC Library Product List" | ||
} | ||
} | ||
} | ||
mock_get_api_json.return_value = mock_response | ||
rule_catalogs = client.get_rule_catalogs() | ||
assert rule_catalogs == mock_response["_links"]["catalogs"] | ||
|
||
@mock.patch('cdisc_library_client.library_client.CDISCLibraryClient.get_api_json') | ||
def test_get_rules_catalog(mock_get_api_json): | ||
client = CDISCLibraryClient(api_key="test") | ||
mock_response = { | ||
"_links": { | ||
"self": { | ||
"href": "/mdr/rules/sdtmig/3-4", | ||
"title": "sdtmig Conformance Rules v3-4", | ||
"type": "Conformance Rules Package" | ||
} | ||
}, | ||
"rules": { | ||
"rule1": 10, | ||
"rule2": 20 | ||
} | ||
} | ||
mock_get_api_json.return_value = mock_response | ||
rules_catalog = client.get_rules_catalog("sdtmig", "3-4") | ||
assert rules_catalog == mock_response["rules"] | ||
|