-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat: re-export Verification Context v1.0 types from qwed_sdk #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8b6f2b4
feat: re-export Verification Context v1.0 types from qwed_sdk
rahuldass19 6a5e649
fix: re-export complete VC model types + add coverage test
rahuldass19 a46240a
test: add dedicated coverage for qwed_sdk/__init__.py re-exports
rahuldass19 1404272
fix: address CodeQL findings + ensure 100% coverage on qwed_sdk/__ini…
rahuldass19 b69ec3c
fix: address all CodeQL/code-quality findings in test_sdk_init.py
rahuldass19 0467b73
fix: use coverage run instead of pytest-cov for SonarCloud
rahuldass19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,176 @@ | ||
| """Coverage for qwed_sdk/__init__.py re-exports.""" | ||
|
|
||
| import importlib | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| def test_sdk_init_module_executes(): | ||
| """Force re-execution of qwed_sdk/__init__.py module-level code for coverage.""" | ||
| if "qwed_sdk" in sys.modules: | ||
| importlib.reload(sys.modules["qwed_sdk"]) | ||
| else: | ||
| from qwed_sdk import __version__ as _ # noqa: F401 | ||
| from qwed_sdk import __all__ as sdk_all, __version__ as sdk_version | ||
| assert sdk_all is not None | ||
| assert sdk_version == "7.0.0" | ||
|
|
||
|
|
||
| def test_sdk_init_exports_verdict_enum(): | ||
| from qwed_sdk import Verdict | ||
| assert Verdict.VERIFIED.value == "VERIFIED" | ||
| assert Verdict.UNVERIFIABLE.value == "UNVERIFIABLE" | ||
| assert Verdict.BLOCKED.value == "BLOCKED" | ||
| assert len(Verdict) == 3 | ||
|
|
||
|
|
||
| def test_sdk_init_exports_admission_enum(): | ||
| from qwed_sdk import Admission | ||
| assert Admission.ADMIT.value == "ADMIT" | ||
| assert Admission.DENY.value == "DENY" | ||
| assert len(Admission) == 2 | ||
|
|
||
|
|
||
| def test_sdk_init_exports_model_classes(): | ||
| from qwed_sdk import ( | ||
| VerificationContext, | ||
| VerificationContextDocument, | ||
| Formalization, | ||
| VerifiedObject, | ||
| Interpretation, | ||
| Proof, | ||
| Evidence, | ||
| Decision, | ||
| ) | ||
| assert VerificationContext is not None | ||
| assert VerificationContextDocument is not None | ||
| assert Formalization is not None | ||
| assert VerifiedObject is not None | ||
| assert Interpretation is not None | ||
| assert Proof is not None | ||
| assert Evidence is not None | ||
| assert Decision is not None | ||
|
|
||
|
|
||
| def test_sdk_init_exports_validation_error(): | ||
| from qwed_sdk import VerificationContextValidationError | ||
| assert issubclass(VerificationContextValidationError, ValueError) | ||
| err = VerificationContextValidationError("test") | ||
| assert str(err) == "test" | ||
|
Check warning on line 60 in tests/test_sdk_init.py
|
||
|
rahuldass19 marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def test_sdk_init_exports_proof_functions(): | ||
| from qwed_sdk import ( | ||
| VerificationContextValidationError, | ||
| compute_context_proof_ref, | ||
| compute_document_proof_ref, | ||
| resolve_document_proof_ref, | ||
| resolve_context_proof_ref, | ||
| validate_document, | ||
| is_valid_document, | ||
| ) | ||
| assert callable(compute_context_proof_ref) | ||
| assert callable(compute_document_proof_ref) | ||
| assert callable(resolve_document_proof_ref) | ||
| assert callable(resolve_context_proof_ref) | ||
| assert callable(validate_document) | ||
| assert callable(is_valid_document) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| with pytest.raises(VerificationContextValidationError): | ||
| validate_document({}) | ||
|
|
||
|
|
||
| def test_sdk_init_all_list_complete(): | ||
| from qwed_sdk import __all__ as sdk_all | ||
| from qwed_sdk import ( | ||
| QWEDClient, | ||
| QWEDAsyncClient, | ||
| QWEDLocal, | ||
| VerificationResult, | ||
| BatchResult, | ||
| VerificationType, | ||
| Verdict, | ||
| Admission, | ||
| VerificationContext, | ||
| VerificationContextDocument, | ||
| VerificationContextValidationError, | ||
| Formalization, | ||
| VerifiedObject, | ||
| Interpretation, | ||
| Proof, | ||
| Evidence, | ||
| Decision, | ||
| compute_context_proof_ref, | ||
| compute_document_proof_ref, | ||
| resolve_document_proof_ref, | ||
| resolve_context_proof_ref, | ||
| validate_document, | ||
| is_valid_document, | ||
| ) | ||
| exported = { | ||
| "QWEDClient": QWEDClient, | ||
| "QWEDAsyncClient": QWEDAsyncClient, | ||
| "QWEDLocal": QWEDLocal, | ||
| "VerificationResult": VerificationResult, | ||
| "BatchResult": BatchResult, | ||
| "VerificationType": VerificationType, | ||
| "Verdict": Verdict, | ||
| "Admission": Admission, | ||
| "VerificationContext": VerificationContext, | ||
| "VerificationContextDocument": VerificationContextDocument, | ||
| "VerificationContextValidationError": VerificationContextValidationError, | ||
| "Formalization": Formalization, | ||
| "VerifiedObject": VerifiedObject, | ||
| "Interpretation": Interpretation, | ||
| "Proof": Proof, | ||
| "Evidence": Evidence, | ||
| "Decision": Decision, | ||
| "compute_context_proof_ref": compute_context_proof_ref, | ||
| "compute_document_proof_ref": compute_document_proof_ref, | ||
| "resolve_document_proof_ref": resolve_document_proof_ref, | ||
| "resolve_context_proof_ref": resolve_context_proof_ref, | ||
| "validate_document": validate_document, | ||
| "is_valid_document": is_valid_document, | ||
| } | ||
| for name, obj in exported.items(): | ||
| assert name in sdk_all, f"{name} missing from __all__" | ||
| assert obj is not None, f"{name} is None" | ||
|
|
||
|
|
||
| def test_sdk_init_is_valid_document_returns_false_for_invalid(): | ||
| from qwed_sdk import is_valid_document | ||
| assert is_valid_document({}) is False | ||
| assert is_valid_document({"spec_version": "99.0"}) is False | ||
|
|
||
|
|
||
| def test_sdk_init_resolve_document_proof_ref_returns_false_for_invalid(): | ||
| from qwed_sdk import resolve_document_proof_ref | ||
| assert resolve_document_proof_ref({}) is False | ||
| assert resolve_document_proof_ref({"verdict": "BLOCKED"}) is False | ||
|
|
||
|
|
||
| def test_sdk_init_get_langchain_tools(): | ||
| from qwed_sdk import get_langchain_tools | ||
| try: | ||
| tools = get_langchain_tools() | ||
| assert "QWEDTool" in tools | ||
| except ImportError as exc: | ||
| pytest.skip(f"langchain is optional: {exc}") | ||
|
|
||
|
|
||
| def test_sdk_init_get_llamaindex_tools(): | ||
| from qwed_sdk import get_llamaindex_tools | ||
| try: | ||
| tools = get_llamaindex_tools() | ||
| assert "QWEDQueryEngine" in tools | ||
| except ImportError as exc: | ||
| pytest.skip(f"llamaindex is optional: {exc}") | ||
|
|
||
|
|
||
| def test_sdk_init_get_crewai_tools(): | ||
| from qwed_sdk import get_crewai_tools | ||
| try: | ||
| tools = get_crewai_tools() | ||
| assert "QWEDVerificationTool" in tools | ||
| except ImportError as exc: | ||
| pytest.skip(f"crewai is optional: {exc}") | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.