-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: validators for cdd,ead, and error pipeline #177
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
33fdf8a
feat: add pydantic dataclassed for cdd ^ ead
johanseto 010583d
feat: add validation for cdd and ead
johanseto 1fac715
feat: rebase compatibility
johanseto 5eba4d2
feat: add validate cdd and ead pipes
johanseto 89b2d5b
feat: add error_validation_task test =)
johanseto 7cd649b
fix: add validation step to rti backends
johanseto 80d39ee
fix: pipeline starts with wrong pipeline_index
johanseto 36b7a4b
feat: keep validation_exception in error_pipeline
johanseto cc7d0fe
chore: fix docstring
johanseto 4046899
chore: improve method name
johanseto 8670080
refactor: error handling with pearson exceptions
johanseto 908e22f
feat: pr recommend remove unuseful block code
johanseto 5e02a8e
refactor: send exception_data in kwarg
johanseto c84f5e9
refactor: change the error raised
johanseto cbd4288
feat: audit with name action variable
johanseto ae1c5da
feat: add skip pipe if not exception_data
johanseto 522a5de
fix: assertNoLogs is only available py3.10+
johanseto c01a829
feat: raise same exception based on exception_data
johanseto 7a20113
refactor: hidden_kwargs 2 rm sensitive keys audit
johanseto c755803
refactor: manage exception with dict representation
johanseto 1b03234
chore: update eox_nelp/pearson_vue/pipeline.py
johanseto d718aca
chore: remove unnused utils
johanseto a9e1fc6
feat: pr recommendation init exc improvemente
johanseto 0f59377
feat: add test for exception file
johanseto 5f61fed
chore: docstrings improvements
johanseto 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
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
""" | ||
Module to add data_classes related Pearson Vue Integration | ||
""" | ||
# pylint: disable=missing-class-docstring | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class Phone(BaseModel): | ||
phone_number: str = Field(alias="phoneNumber", min_length=1, max_length=20) | ||
phone_country_code: str = Field(alias="phoneCountryCode", min_length=1, max_length=3) | ||
|
||
|
||
class Mobile(BaseModel): | ||
mobile_number: str = Field(alias="mobileNumber", min_length=1, max_length=20) | ||
mobile_country_code: str = Field(alias="mobileCountryCode", min_length=1, max_length=3) | ||
|
||
|
||
class NativeAddress(BaseModel): | ||
language: str = Field(alias="language", min_length=3, max_length=3) | ||
potential_mismatch: str = Field(alias="potentialMismatch", min_length=1) | ||
first_name: str = Field(alias="firstName", min_length=1, max_length=30) | ||
last_name: str = Field(alias="lastName", min_length=1, max_length=50) | ||
address1: str = Field(alias="address1", min_length=1, max_length=40) | ||
city: str = Field(alias="city", min_length=1, max_length=32) | ||
|
||
|
||
class Address(BaseModel): | ||
address1: str = Field(alias="address1", min_length=1, max_length=40) | ||
city: str = Field(alias="city", min_length=1, max_length=32) | ||
country: str = Field(alias="country", min_length=1, max_length=3) | ||
phone: Phone = Field(alias="phone") | ||
mobile: Mobile = Field(alias="mobile") | ||
native_address: NativeAddress = Field(alias="nativeAddress") | ||
|
||
|
||
class PrimaryAddress(Address): | ||
pass | ||
|
||
|
||
class AlternateAddress(Address): | ||
pass | ||
|
||
|
||
class CandidateName(BaseModel): | ||
first_name: str = Field(alias="firstName", min_length=1, max_length=30) | ||
last_name: str = Field(alias="lastName", min_length=1, max_length=50) | ||
|
||
|
||
class WebAccountInfo(BaseModel): | ||
email: str = Field(alias="email", min_length=1, max_length=255) | ||
|
||
|
||
class CddRequest(BaseModel): | ||
client_candidate_id: str = Field(alias="@clientCandidateID", min_length=1, max_length=50) | ||
client_id: str = Field(alias="@clientID", min_length=1) | ||
candidate_name: CandidateName = Field(alias="candidateName") | ||
last_update: str = Field(alias="lastUpdate", min_length=1) | ||
primary_address: PrimaryAddress = Field(alias="primaryAddress") | ||
web_account_info: WebAccountInfo = Field(alias="webAccountInfo") | ||
|
||
|
||
class EadRequest(BaseModel): | ||
client_id: str = Field(alias="@clientID", min_length=1) | ||
authorization_transaction_type: str = Field(alias="@authorizationTransactionType", min_length=1) | ||
client_authorization_id: str = Field(alias="@clientAuthorizationID", min_length=1, max_length=25) | ||
client_candidate_id: str = Field(alias="clientCandidateID", min_length=1, max_length=50) | ||
exam_authorization_count: int = Field(alias="examAuthorizationCount") | ||
exam_series_code: str = Field(alias="examSeriesCode", min_length=1, max_length=20) | ||
elegibility_appt_date_first: str = Field(alias="eligibilityApptDateFirst", min_length=1) | ||
elegibility_appt_date_last: str = Field(alias="eligibilityApptDateLast", min_length=1) | ||
last_update: str = Field(alias="lastUpdate", min_length=1) |
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,90 @@ | ||
""" | ||
Module to add managed exceptions related Pearson Vue Integration | ||
""" | ||
import inspect | ||
|
||
|
||
class PearsonBaseError(Exception): | ||
"""Pearson Base error class | ||
Most classes that inherit from this class must have exception_type. | ||
""" | ||
exception_type = "base-error" | ||
|
||
def __init__( | ||
self, | ||
exception_reason, | ||
*args, | ||
pipe_frame=None, | ||
pipe_args_dict=None, | ||
pipe_function=None, | ||
**kwargs | ||
): # pylint: disable=unused-argument | ||
"""Init pearson exception.Is mandatory the exception_reasons. | ||
You could init using pipe_frame | ||
Or init using exception_dict representation with **kwargs. | ||
That representation should have the following shape: | ||
exception_dict = { | ||
'exception_type': 'validation-error', | ||
'pipe_args_dict': { | ||
"cdd_request": {} | ||
}, | ||
'pipe_function': 'validate_cdd_request', | ||
'exception_reason': "error: ['String to short.']" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update this |
||
""" | ||
|
||
self.exception_type = self.exception_type | ||
andrey-canon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.exception_reason = exception_reason | ||
|
||
if pipe_frame: | ||
arg_info = inspect.getargvalues(pipe_frame) | ||
self.pipe_args_dict = {arg: arg_info.locals[arg] for arg in arg_info.args} | ||
self.pipe_function = pipe_frame.f_code.co_name | ||
else: | ||
self.pipe_args_dict = pipe_args_dict | ||
self.pipe_function = pipe_function | ||
|
||
super().__init__(self.to_dict(), *args) | ||
|
||
def to_dict(self): | ||
""" | ||
Returns a dictionary representation of the class instance. | ||
|
||
Returns: | ||
A dictionary containing the instance's attributes as key-value pairs. | ||
""" | ||
|
||
return {key: value for key, value in self.__dict__.items() if not key.startswith('_')} | ||
|
||
@classmethod | ||
def from_dict(cls, exception_dict: dict): | ||
"""Create an instance of Person or its subclass from a dictionary. | ||
Returns: | ||
Matched instance of pearson exception subclass initialized. | ||
If not matched returns the base class initialized by default. | ||
""" | ||
exception_type = exception_dict.get('exception_type') | ||
for subclass in cls.__subclasses__(): | ||
if subclass.exception_type == exception_type: | ||
return subclass(**exception_dict) | ||
|
||
# Default to Person if no matching subclass is found | ||
return cls(**exception_dict) | ||
|
||
johanseto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class PearsonKeyError(PearsonBaseError): | ||
"""Pearson Key error class | ||
""" | ||
exception_type = "key-error" | ||
|
||
|
||
class PearsonAttributeError(PearsonBaseError): | ||
"""Pearson Attribute error class | ||
""" | ||
exception_type = "attribute-error" | ||
|
||
|
||
class PearsonValidationError(PearsonBaseError): | ||
"""Pearson Validation error class | ||
""" | ||
exception_type = "validation-error" |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-.-