Skip to content

Commit

Permalink
core: making subtype property from Connector object mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas committed Sep 5, 2024
1 parent 9fb79a6 commit 65f24f0
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/adzuna/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def format_job(
Adzuna = Connector(
name="Adzuna",
type=ConnectorType.JobBoard,
subtype="adzuna",
description="Retrieve Adzuna's job, property and car advertisement listings.",
url="https://www.adzuna.fr/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/breezyhr/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def format_candidate(breezy_profile: BreezyProfileModel) -> HrFlowProfile:
BreezyHR = Connector(
name="BreezyHR",
type=ConnectorType.ATS,
subtype="breezyhr",
description=(
"Breezyhr is an end-to-end recruiting software "
"to help you attract & hire great employees with less effort"
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/bullhorn/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ def format_application(data: HrFlowProfile) -> t.Dict:
Bullhorn = Connector(
name="Bullhorn",
type=ConnectorType.ATS,
subtype="bullhorn",
description=DESCRIPTION,
url="https://www.bullhorn.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/carrevolutis/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def event_parser(event: t.Dict) -> t.Dict:
Carrevolutis = Connector(
name="Carrevolutis",
type=ConnectorType.JobBoard,
subtype="carrevolutis",
description=DESCRIPTION,
url="https://www.carrevolutis.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/ceridian/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def format_job(data: CeridianDayforceJobModel) -> t.Dict:
Ceridian = Connector(
name="Ceridian",
type=ConnectorType.HCM,
subtype="ceridian",
description=DESCRIPTION,
url="https://www.ceridian.com/",
actions=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def format_profile(profile_hrflow: t.Dict) -> t.Dict:
DigitalRecruiters = Connector(
name="DigitalRecruiters",
type=ConnectorType.ATS,
subtype="digitalrecruiters",
description=DESCRIPTION,
url="https://www.digitalrecruiters.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/greenhouse/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def format_to_hrflow_profile(data):
Greenhouse = Connector(
name="Greenhouse",
type=ConnectorType.ATS,
subtype="greenhouse",
description="",
url="https://www.greenhouse.io/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/hubspot/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def format_hubspot_contact(hubspot_contact: t.Dict) -> t.Dict:
Hubspot = Connector(
name="Hubspot",
type=ConnectorType.CRM,
subtype="hubspot",
description="",
url="https://www.hubspot.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/jobology/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def event_parser(event: t.Dict) -> t.Dict:
Jobology = Connector(
name="Jobology",
type=ConnectorType.JobBoard,
subtype="jobology",
description=DESCRIPTION,
url="https://www.jobology.fr/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/lever/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def format_opportunity(hrflow_profile: dict) -> dict:
Lever = Connector(
name="Lever",
type=ConnectorType.ATS,
subtype="lever",
description=DESCRIPTION,
url="https://www.lever.co/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/meteojob/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def event_parser(event: t.Dict) -> t.Dict:
Meteojob = Connector(
name="Meteojob",
type=ConnectorType.JobBoard,
subtype="meteojob",
description=DESCRIPTION,
url="https://www.meteojob.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/poleemploi/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def format_job(
PoleEmploi = Connector(
name="PoleEmploi",
type=ConnectorType.JobBoard,
subtype="poleemploi",
description=DESCRIPTION,
url="https://www.pole-emploi.fr/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/recruitee/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def format_job(recruitee_job: t.Dict) -> t.Dict:
Recruitee = Connector(
name="Recruitee",
type=ConnectorType.ATS,
subtype="recruitee",
description="",
url="https://recruitee.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/salesforce/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def format_job(data: SalesforceHrFlowJob) -> t.Dict:
Salesforce = Connector(
name="Salesforce",
type=ConnectorType.CRM,
subtype="salesforce",
description=DESCRIPTION,
url="https://www.salesforce.com",
actions=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def format_sap_candidate(candidate_data: t.Dict) -> t.Dict:
SAPSuccessFactors = Connector(
name="SAPSuccessFactors",
type=ConnectorType.ATS,
subtype="sapsuccessfactors",
description=DESCRIPTION,
url="https://www.sap.com/",
actions=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def format_profile(hrflow_profile: t.Dict) -> t.Dict:
SmartRecruiters = Connector(
name="SmartRecruiters",
type=ConnectorType.ATS,
subtype="smartrecruiters",
description=DESCRIPTION,
url="https://www.smartrecruiters.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/taleez/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def format_job(taleez_job: t.Dict) -> t.Dict:
Taleez = Connector(
name="Taleez",
type=ConnectorType.ATS,
subtype="taleez",
description=DESCRIPTION,
url="https://taleez.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/talentsoft/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def format_info_ts_applicant(profile_hrflow: t.Dict) -> t.Dict:
TalentSoft = Connector(
name="TalentSoft",
type=ConnectorType.HCM,
subtype="talentsoft",
description=DESCRIPTION,
url="https://www.cegid.com/fr/produits/cegid-talentsoft/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/teamtailor/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def format_profile(data: HrFlowProfile) -> t.Dict:
Teamtailor = Connector(
name="Teamtailor",
type=ConnectorType.ATS,
subtype="teamtailor",
description=DESCRIPTION,
url="https://www.teamtailor.com/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/waalaxy/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def event_parser(event: t.Dict) -> t.Dict:
Waalaxy = Connector(
name="Waalaxy",
type=ConnectorType.Automation,
subtype="waalaxy",
description=DESCRIPTION,
url="https://www.waalaxy.com/fr/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions src/hrflow_connectors/connectors/workable/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def format_profile(
Workable = Connector(
name="Workable",
type=ConnectorType.HCM,
subtype="workable",
description=(
"More than an applicant tracking system, "
"Workable's talent acquisition software helps teams find candidates, "
Expand Down
19 changes: 3 additions & 16 deletions src/hrflow_connectors/core/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,25 +764,12 @@ class ConnectorModel(BaseModel):
description: str
url: str
type: ConnectorType
subtype: t.Optional[str] = Field(
subtype: str = Field(
regex=CONNECTOR_SUBTYPE_FORMAT_REGEX,
description="Lowercased string with no spaces",
)
actions: t.List[ConnectorAction]

@validator("subtype", pre=True, always=True)
def check_subtype(cls, value: t.Optional[str], values: dict) -> str:
if value is None:
cleaned_value = values.get("name", "").lower().replace(" ", "")
else:
cleaned_value = value.lower().replace(" ", "")
if cleaned_value != value:
raise ValueError(
"ConnectorModel's `subtype`={} must be lowercase without any"
" spaces.".format(value)
)
return cleaned_value

def logo(self, connectors_directory: Path) -> str:
try:
from PIL import Image, UnidentifiedImageError
Expand Down Expand Up @@ -861,11 +848,11 @@ def based_on(
base: t.Self,
name: str,
type: ConnectorType,
subtype: str,
description: str,
url: str,
with_parameters_override: t.Optional[t.List[ParametersOverride]] = None,
with_actions: t.Optional[t.List[ConnectorAction]] = None,
subtype: t.Optional[str] = None,
) -> t.Self:
base_actions = base.model.actions

Expand Down Expand Up @@ -913,7 +900,7 @@ def based_on(
connector = cls(
name=name,
type=type,
subtype=name.lower().replace(" ", "") if subtype is None else subtype,
subtype=subtype,
description=description,
url=url,
actions=list(actions.values()),
Expand Down
15 changes: 15 additions & 0 deletions tests/core/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
SmartLeadsF = lambda: Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -94,6 +95,7 @@ def test_action_name_constraint():
Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand All @@ -119,6 +121,7 @@ def test_action_pull_profile_list_only_with_trigger_type_pull():
Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -148,6 +151,7 @@ def test_action_pull_job_list_only_with_trigger_type_pull():
Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -177,6 +181,7 @@ def test_action_pull_application_list_only_with_trigger_type_pull():
Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -254,6 +259,7 @@ def test_origin_warehouse_failure():
connector = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -285,6 +291,7 @@ def test_origin_not_readable_failure():
Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand All @@ -309,6 +316,7 @@ def test_target_warehouse_failure():
connector = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -340,6 +348,7 @@ def test_target_not_writable_failure():
Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -505,6 +514,7 @@ def smarter_format(user):
EvenSmarterLeads = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -589,6 +599,7 @@ def failing_logic(user):
FailingSmartLeads = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -735,6 +746,7 @@ def callback(origin_parameters, target_parameters, events, written_items) -> Non
SmartLeads = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -779,6 +791,7 @@ def callback(origin_parameters, target_parameters, events, written_items) -> Non
SmartLeads = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -1674,6 +1687,7 @@ def test_connector_model_subtype_missing():
model = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[],
Expand All @@ -1687,6 +1701,7 @@ def test_connector_subtype_constraint():
Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
subtype=subtype,
description=DESCRIPTION,
url="https://www.smartleads.test/",
Expand Down
3 changes: 3 additions & 0 deletions tests/core/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
SmartLeads = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -643,6 +644,7 @@ def test_documentation_connector_directory_not_found(caplog, connectors_director
NameMismatchSmartLeads = Connector(
name=mismatch_name,
type=ConnectorType.Other,
subtype=mismatch_name.lower().replace(" ", ""),
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down Expand Up @@ -716,6 +718,7 @@ def test_documentation_fails_if_connector_not_already_listed_in_root_readme(
NotListed = Connector(
name=name,
type=ConnectorType.Other,
subtype=name.lower().replace(" ", ""),
description=DESCRIPTION,
url="https://not.listed.in.root.test/",
actions=[
Expand Down
1 change: 1 addition & 0 deletions tests/core/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
SmartLeads = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description=DESCRIPTION,
url="https://www.smartleads.test/",
actions=[
Expand Down
2 changes: 2 additions & 0 deletions tests/core/test_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
SmartLeads = Connector(
name="SmartLeads",
type=ConnectorType.Other,
subtype="smartleads",
description="Test Connector for seamless users to leads integration",
url="https://www.smartleads.test/",
actions=[
Expand All @@ -59,6 +60,7 @@
LocalUsers = Connector(
name="LocalUsers",
type=ConnectorType.Other,
subtype="localusers",
description="Local users connector",
url="https://www.localusers.test/",
actions=[],
Expand Down

0 comments on commit 65f24f0

Please sign in to comment.