-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ac3a61
commit 5239c73
Showing
5 changed files
with
114 additions
and
4 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
42 changes: 42 additions & 0 deletions
42
yoti_python_sandbox/doc_scan/check/sandbox_third_party_check.py
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,42 @@ | ||
from yoti_python_sandbox.doc_scan.check.sandbox_check import SandboxCheckBuilder | ||
from yoti_python_sandbox.doc_scan.check.sandbox_check_report import SandboxCheckReport | ||
from yoti_python_sandbox.doc_scan.check.sandbox_check_result import SandboxCheckResult | ||
from .sandbox_check import SandboxCheck | ||
|
||
|
||
class SandboxThirdPartyCheck(SandboxCheck): | ||
def __init__(self, result, manual_check): | ||
SandboxCheck.__init__(self, result) | ||
self.__manual_check = manual_check | ||
|
||
@property | ||
def type(self): | ||
return "THIRD_PARTY_IDENTITY" | ||
|
||
@property | ||
def manual_check(self): | ||
return self.__manual_check | ||
|
||
def to_json(self): | ||
parent = SandboxCheck.to_json(self) | ||
parent["type"] = self.type | ||
parent["manual_check"] = self.manual_check | ||
|
||
return parent | ||
|
||
|
||
class SandboxThirdPartyCheckBuilder(SandboxCheckBuilder): | ||
def __init__(self): | ||
SandboxCheckBuilder.__init__(self) | ||
self.__manual_check = None | ||
|
||
def with_manual_check(self, manual_check): | ||
self.__manual_check = manual_check | ||
|
||
return self | ||
|
||
def build(self): | ||
report = SandboxCheckReport(self.recommendation, self.breakdown) | ||
result = SandboxCheckResult(report) | ||
|
||
return SandboxThirdPartyCheck(result, self.__manual_check) |
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
31 changes: 31 additions & 0 deletions
31
yoti_python_sandbox/tests/doc_scan/check/test_sandbox_third_party_check.py
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,31 @@ | ||
from mock import Mock | ||
|
||
from yoti_python_sandbox.doc_scan.check import SandboxThirdPartyCheckBuilder | ||
from yoti_python_sandbox.doc_scan.check.report.recommendation import ( | ||
SandboxRecommendation, | ||
) | ||
from yoti_python_sandbox.doc_scan.check.report.breakdown import SandboxBreakdown | ||
|
||
|
||
def test_third_party_check_should_set_correct_manual_check_and_type(): | ||
check = SandboxThirdPartyCheckBuilder().with_manual_check("NEVER") | ||
|
||
assert check.manual_check == "NEVER" | ||
assert check.type == "THIRD_PARTY_IDENTITY" | ||
|
||
|
||
def test_third_party_check_build_result_object(): | ||
recommendation_mock = Mock(spec=SandboxRecommendation) | ||
breakdown_mock = Mock(spec=SandboxBreakdown) | ||
|
||
check = ( | ||
SandboxThirdPartyCheckBuilder() | ||
.with_recommendation(recommendation_mock) | ||
.with_breakdown(breakdown_mock) | ||
.build() | ||
) | ||
|
||
assert check.result.report.recommendation is not None | ||
assert check.result.report.recommendation == recommendation_mock | ||
assert len(check.result.report.breakdown) == 1 | ||
assert check.result.report.breakdown[0] == breakdown_mock |
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