-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Add tests and fixes for protobuf references support
- Loading branch information
1 parent
7c36fe0
commit 9dd1c60
Showing
13 changed files
with
882 additions
and
291 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,21 +1,47 @@ | ||
from typing import Optional, TYPE_CHECKING | ||
from karapace.schema_references import Reference | ||
from karapace.typing import JsonData, Subject, Version | ||
from typing import Any, Optional, TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from karapace.schema_models import ValidatedTypedSchema | ||
|
||
|
||
class DependencyVerifierResult: | ||
def __init__(self, result: bool, message: Optional[str] = "") -> None: | ||
self.result = result | ||
self.message = message | ||
|
||
|
||
class Dependency: | ||
def __init__(self, name: str, subject: str, version: int, schema: "ValidatedTypedSchema") -> None: | ||
def __init__(self, name: str, subject: Subject, version: Version, target_schema: "ValidatedTypedSchema") -> None: | ||
self.name = name | ||
self.subject = subject | ||
self.version = version | ||
self.schema = schema | ||
self.schema = target_schema | ||
|
||
@staticmethod | ||
def of(reference: Reference, target_schema: "ValidatedTypedSchema") -> "Dependency": | ||
return Dependency(reference.name, reference.subject, reference.version, target_schema) | ||
|
||
def to_dict(self) -> JsonData: | ||
return { | ||
"name": self.name, | ||
"subject": self.subject, | ||
"version": self.version, | ||
} | ||
|
||
def identifier(self) -> str: | ||
return self.name + "_" + self.subject + "_" + str(self.version) | ||
|
||
def __hash__(self) -> int: | ||
return hash((self.name, self.subject, self.version, self.schema)) | ||
|
||
class DependencyVerifierResult: | ||
def __init__(self, result: bool, message: Optional[str] = ""): | ||
self.result = result | ||
self.message = message | ||
def __eq__(self, other: Any) -> bool: | ||
if other is None or not isinstance(other, Dependency): | ||
return False | ||
return ( | ||
self.name == other.name | ||
and self.subject == other.subject | ||
and self.version == other.version | ||
and self.schema == other.schema | ||
) |
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
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
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
Oops, something went wrong.