diff --git a/.vscode/launch.json b/.vscode/launch.json index 1e448018d5..458d6c3447 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -130,9 +130,7 @@ "python": "${workspaceFolder}/.venv/bin/python", "request": "launch", "type": "debugpy", - "args": [ - "new" - ] + "args": ["new"] } ] } diff --git a/integrations/hibob/hibob/client.py b/integrations/hibob/hibob/client.py index dd7834fdf4..3143225bb5 100644 --- a/integrations/hibob/hibob/client.py +++ b/integrations/hibob/hibob/client.py @@ -9,7 +9,9 @@ def __init__(self, api_url: str, username: str, password: str): self.api_url = api_url self.username = username self.password = password - logger.info(f"Initializing Hibob client with API {api_url} and API service username {username}") + logger.info( + f"Initializing Hibob client with API {api_url} and API service username {username}" + ) self.client = http_async_client self.client.auth = BasicAuth(username, password) self.client.timeout = Timeout(30) diff --git a/integrations/hibob/poetry.lock b/integrations/hibob/poetry.lock index 81cad50adb..9436277829 100644 --- a/integrations/hibob/poetry.lock +++ b/integrations/hibob/poetry.lock @@ -786,43 +786,49 @@ files = [ [[package]] name = "mypy" -version = "1.14.0" +version = "1.14.1" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ - {file = "mypy-1.14.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e971c1c667007f9f2b397ffa80fa8e1e0adccff336e5e77e74cb5f22868bee87"}, - {file = "mypy-1.14.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e86aaeaa3221a278c66d3d673b297232947d873773d61ca3ee0e28b2ff027179"}, - {file = "mypy-1.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1628c5c3ce823d296e41e2984ff88c5861499041cb416a8809615d0c1f41740e"}, - {file = "mypy-1.14.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:7fadb29b77fc14a0dd81304ed73c828c3e5cde0016c7e668a86a3e0dfc9f3af3"}, - {file = "mypy-1.14.0-cp310-cp310-win_amd64.whl", hash = "sha256:3fa76988dc760da377c1e5069200a50d9eaaccf34f4ea18428a3337034ab5a44"}, - {file = "mypy-1.14.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6e73c8a154eed31db3445fe28f63ad2d97b674b911c00191416cf7f6459fd49a"}, - {file = "mypy-1.14.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:273e70fcb2e38c5405a188425aa60b984ffdcef65d6c746ea5813024b68c73dc"}, - {file = "mypy-1.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1daca283d732943731a6a9f20fdbcaa927f160bc51602b1d4ef880a6fb252015"}, - {file = "mypy-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:7e68047bedb04c1c25bba9901ea46ff60d5eaac2d71b1f2161f33107e2b368eb"}, - {file = "mypy-1.14.0-cp311-cp311-win_amd64.whl", hash = "sha256:7a52f26b9c9b1664a60d87675f3bae00b5c7f2806e0c2800545a32c325920bcc"}, - {file = "mypy-1.14.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d5326ab70a6db8e856d59ad4cb72741124950cbbf32e7b70e30166ba7bbf61dd"}, - {file = "mypy-1.14.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bf4ec4980bec1e0e24e5075f449d014011527ae0055884c7e3abc6a99cd2c7f1"}, - {file = "mypy-1.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:390dfb898239c25289495500f12fa73aa7f24a4c6d90ccdc165762462b998d63"}, - {file = "mypy-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7e026d55ddcd76e29e87865c08cbe2d0104e2b3153a523c529de584759379d3d"}, - {file = "mypy-1.14.0-cp312-cp312-win_amd64.whl", hash = "sha256:585ed36031d0b3ee362e5107ef449a8b5dfd4e9c90ccbe36414ee405ee6b32ba"}, - {file = "mypy-1.14.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e9f6f4c0b27401d14c483c622bc5105eff3911634d576bbdf6695b9a7c1ba741"}, - {file = "mypy-1.14.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:56b2280cedcb312c7a79f5001ae5325582d0d339bce684e4a529069d0e7ca1e7"}, - {file = "mypy-1.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:342de51c48bab326bfc77ce056ba08c076d82ce4f5a86621f972ed39970f94d8"}, - {file = "mypy-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:00df23b42e533e02a6f0055e54de9a6ed491cd8b7ea738647364fd3a39ea7efc"}, - {file = "mypy-1.14.0-cp313-cp313-win_amd64.whl", hash = "sha256:e8c8387e5d9dff80e7daf961df357c80e694e942d9755f3ad77d69b0957b8e3f"}, - {file = "mypy-1.14.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b16738b1d80ec4334654e89e798eb705ac0c36c8a5c4798496cd3623aa02286"}, - {file = "mypy-1.14.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:10065fcebb7c66df04b05fc799a854b1ae24d9963c8bb27e9064a9bdb43aa8ad"}, - {file = "mypy-1.14.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fbb7d683fa6bdecaa106e8368aa973ecc0ddb79a9eaeb4b821591ecd07e9e03c"}, - {file = "mypy-1.14.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:3498cb55448dc5533e438cd13d6ddd28654559c8c4d1fd4b5ca57a31b81bac01"}, - {file = "mypy-1.14.0-cp38-cp38-win_amd64.whl", hash = "sha256:c7b243408ea43755f3a21a0a08e5c5ae30eddb4c58a80f415ca6b118816e60aa"}, - {file = "mypy-1.14.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:14117b9da3305b39860d0aa34b8f1ff74d209a368829a584eb77524389a9c13e"}, - {file = "mypy-1.14.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:af98c5a958f9c37404bd4eef2f920b94874507e146ed6ee559f185b8809c44cc"}, - {file = "mypy-1.14.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f0b343a1d3989547024377c2ba0dca9c74a2428ad6ed24283c213af8dbb0710b"}, - {file = "mypy-1.14.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:cdb5563c1726c85fb201be383168f8c866032db95e1095600806625b3a648cb7"}, - {file = "mypy-1.14.0-cp39-cp39-win_amd64.whl", hash = "sha256:74e925649c1ee0a79aa7448baf2668d81cc287dc5782cff6a04ee93f40fb8d3f"}, - {file = "mypy-1.14.0-py3-none-any.whl", hash = "sha256:2238d7f93fc4027ed1efc944507683df3ba406445a2b6c96e79666a045aadfab"}, - {file = "mypy-1.14.0.tar.gz", hash = "sha256:822dbd184d4a9804df5a7d5335a68cf7662930e70b8c1bc976645d1509f9a9d6"}, + {file = "mypy-1.14.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:52686e37cf13d559f668aa398dd7ddf1f92c5d613e4f8cb262be2fb4fedb0fcb"}, + {file = "mypy-1.14.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1fb545ca340537d4b45d3eecdb3def05e913299ca72c290326be19b3804b39c0"}, + {file = "mypy-1.14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:90716d8b2d1f4cd503309788e51366f07c56635a3309b0f6a32547eaaa36a64d"}, + {file = "mypy-1.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2ae753f5c9fef278bcf12e1a564351764f2a6da579d4a81347e1d5a15819997b"}, + {file = "mypy-1.14.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e0fe0f5feaafcb04505bcf439e991c6d8f1bf8b15f12b05feeed96e9e7bf1427"}, + {file = "mypy-1.14.1-cp310-cp310-win_amd64.whl", hash = "sha256:7d54bd85b925e501c555a3227f3ec0cfc54ee8b6930bd6141ec872d1c572f81f"}, + {file = "mypy-1.14.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f995e511de847791c3b11ed90084a7a0aafdc074ab88c5a9711622fe4751138c"}, + {file = "mypy-1.14.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d64169ec3b8461311f8ce2fd2eb5d33e2d0f2c7b49116259c51d0d96edee48d1"}, + {file = "mypy-1.14.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ba24549de7b89b6381b91fbc068d798192b1b5201987070319889e93038967a8"}, + {file = "mypy-1.14.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:183cf0a45457d28ff9d758730cd0210419ac27d4d3f285beda038c9083363b1f"}, + {file = "mypy-1.14.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f2a0ecc86378f45347f586e4163d1769dd81c5a223d577fe351f26b179e148b1"}, + {file = "mypy-1.14.1-cp311-cp311-win_amd64.whl", hash = "sha256:ad3301ebebec9e8ee7135d8e3109ca76c23752bac1e717bc84cd3836b4bf3eae"}, + {file = "mypy-1.14.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:30ff5ef8519bbc2e18b3b54521ec319513a26f1bba19a7582e7b1f58a6e69f14"}, + {file = "mypy-1.14.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cb9f255c18052343c70234907e2e532bc7e55a62565d64536dbc7706a20b78b9"}, + {file = "mypy-1.14.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8b4e3413e0bddea671012b063e27591b953d653209e7a4fa5e48759cda77ca11"}, + {file = "mypy-1.14.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:553c293b1fbdebb6c3c4030589dab9fafb6dfa768995a453d8a5d3b23784af2e"}, + {file = "mypy-1.14.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fad79bfe3b65fe6a1efaed97b445c3d37f7be9fdc348bdb2d7cac75579607c89"}, + {file = "mypy-1.14.1-cp312-cp312-win_amd64.whl", hash = "sha256:8fa2220e54d2946e94ab6dbb3ba0a992795bd68b16dc852db33028df2b00191b"}, + {file = "mypy-1.14.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:92c3ed5afb06c3a8e188cb5da4984cab9ec9a77ba956ee419c68a388b4595255"}, + {file = "mypy-1.14.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:dbec574648b3e25f43d23577309b16534431db4ddc09fda50841f1e34e64ed34"}, + {file = "mypy-1.14.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8c6d94b16d62eb3e947281aa7347d78236688e21081f11de976376cf010eb31a"}, + {file = "mypy-1.14.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d4b19b03fdf54f3c5b2fa474c56b4c13c9dbfb9a2db4370ede7ec11a2c5927d9"}, + {file = "mypy-1.14.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:0c911fde686394753fff899c409fd4e16e9b294c24bfd5e1ea4675deae1ac6fd"}, + {file = "mypy-1.14.1-cp313-cp313-win_amd64.whl", hash = "sha256:8b21525cb51671219f5307be85f7e646a153e5acc656e5cebf64bfa076c50107"}, + {file = "mypy-1.14.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:7084fb8f1128c76cd9cf68fe5971b37072598e7c31b2f9f95586b65c741a9d31"}, + {file = "mypy-1.14.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:8f845a00b4f420f693f870eaee5f3e2692fa84cc8514496114649cfa8fd5e2c6"}, + {file = "mypy-1.14.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:44bf464499f0e3a2d14d58b54674dee25c031703b2ffc35064bd0df2e0fac319"}, + {file = "mypy-1.14.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c99f27732c0b7dc847adb21c9d47ce57eb48fa33a17bc6d7d5c5e9f9e7ae5bac"}, + {file = "mypy-1.14.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:bce23c7377b43602baa0bd22ea3265c49b9ff0b76eb315d6c34721af4cdf1d9b"}, + {file = "mypy-1.14.1-cp38-cp38-win_amd64.whl", hash = "sha256:8edc07eeade7ebc771ff9cf6b211b9a7d93687ff892150cb5692e4f4272b0837"}, + {file = "mypy-1.14.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3888a1816d69f7ab92092f785a462944b3ca16d7c470d564165fe703b0970c35"}, + {file = "mypy-1.14.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:46c756a444117c43ee984bd055db99e498bc613a70bbbc120272bd13ca579fbc"}, + {file = "mypy-1.14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:27fc248022907e72abfd8e22ab1f10e903915ff69961174784a3900a8cba9ad9"}, + {file = "mypy-1.14.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:499d6a72fb7e5de92218db961f1a66d5f11783f9ae549d214617edab5d4dbdbb"}, + {file = "mypy-1.14.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:57961db9795eb566dc1d1b4e9139ebc4c6b0cb6e7254ecde69d1552bf7613f60"}, + {file = "mypy-1.14.1-cp39-cp39-win_amd64.whl", hash = "sha256:07ba89fdcc9451f2ebb02853deb6aaaa3d2239a236669a63ab3801bbf923ef5c"}, + {file = "mypy-1.14.1-py3-none-any.whl", hash = "sha256:b66a60cc4073aeb8ae00057f9c1f64d49e90f918fbcef9a977eb121da8b8f1d1"}, + {file = "mypy-1.14.1.tar.gz", hash = "sha256:7ec88144fe9b510e8475ec2f5f251992690fcf89ccb4500b214b4226abcd32d6"}, ] [package.dependencies] @@ -1081,13 +1087,13 @@ dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments [[package]] name = "pytest-asyncio" -version = "0.25.0" +version = "0.25.1" description = "Pytest support for asyncio" optional = false python-versions = ">=3.9" files = [ - {file = "pytest_asyncio-0.25.0-py3-none-any.whl", hash = "sha256:db5432d18eac6b7e28b46dcd9b69921b55c3b1086e85febfe04e70b18d9e81b3"}, - {file = "pytest_asyncio-0.25.0.tar.gz", hash = "sha256:8c0610303c9e0442a5db8604505fc0f545456ba1528824842b37b4a626cbf609"}, + {file = "pytest_asyncio-0.25.1-py3-none-any.whl", hash = "sha256:c84878849ec63ff2ca509423616e071ef9cd8cc93c053aa33b5b8fb70a990671"}, + {file = "pytest_asyncio-0.25.1.tar.gz", hash = "sha256:79be8a72384b0c917677e00daa711e07db15259f4d23203c59012bcd989d4aee"}, ] [package.dependencies] @@ -1540,4 +1546,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "a846c1109d087e4e48e4efd640bba771b18d3db5b8807ed8ad71ae499a2f1188" +content-hash = "27027e76a702b9921a4d4dc421938a0b21e4e74464849b43b17fc06ac8dcb31f" diff --git a/integrations/hibob/pyproject.toml b/integrations/hibob/pyproject.toml index 621958a79c..f2fee9c8bf 100644 --- a/integrations/hibob/pyproject.toml +++ b/integrations/hibob/pyproject.toml @@ -6,9 +6,11 @@ authors = ["Arseny Neustroev "] [tool.poetry.dependencies] python = "^3.12" -port_ocean = { version = "^0.16.0", extras = ["cli"] } +port_ocean = {version = "^0.17.2", extras = ["cli"]} httpx = "^0.27.0" loguru = "^0.7.3" +pytest = "^8.3.4" +pytest-httpx = ">=0.30.0" [tool.poetry.group.dev.dependencies] # Uncomment this if you want to debug the ocean core together with your integration diff --git a/integrations/hibob/tests/conftest.py b/integrations/hibob/tests/conftest.py new file mode 100644 index 0000000000..4233c6c84c --- /dev/null +++ b/integrations/hibob/tests/conftest.py @@ -0,0 +1,16 @@ +from typing import Any + +from port_ocean.tests.helpers.fixtures import ( + get_mocked_ocean_app, + get_mock_ocean_resource_configs, +) +import pytest + + +def pytest_collection_modifyitems(session: Any, config: Any, items: Any) -> None: + for item in items: + # This allows us to re-requestd the same mocked endpoint several times + item.add_marker(pytest.mark.httpx_mock(can_send_already_matched_responses=True)) + + +# ruff: noqa diff --git a/integrations/hibob/tests/test_sample.py b/integrations/hibob/tests/test_sample.py deleted file mode 100644 index dc80e299c8..0000000000 --- a/integrations/hibob/tests/test_sample.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_example() -> None: - assert 1 == 1 diff --git a/integrations/hibob/tests/test_sync.py b/integrations/hibob/tests/test_sync.py new file mode 100644 index 0000000000..15d1092ddf --- /dev/null +++ b/integrations/hibob/tests/test_sync.py @@ -0,0 +1,309 @@ +from pydantic import BaseModel +import pytest +import os +from pytest_httpx import HTTPXMock +from typing import Any +from port_ocean.tests.helpers.ocean_app import ( + get_raw_result_on_integration_sync_resource_config, +) +import re + + +class TenureDuration(BaseModel): + period_iso: str + sort_factor: int + humanize: str + + +class ReportsTo(BaseModel): + display_name: str + email: str + surname: str + first_name: str + id: str + + +class CustomColumns(BaseModel): + column_1689923448119: str + column_1708713324447: str + column_1659977358302: str + + +class Work(BaseModel): + start_date: str + manager: str + work_phone: str + tenure_duration: TenureDuration + reports_to: ReportsTo + indirect_reports: int + site_id: int + department: str + tenure_years: int + custom_columns: CustomColumns + is_manager: bool + title: str + site: str + direct_reports: int + + +class Profile(BaseModel): + display_name: str + work: Work + company_id: int + email: str + surname: str + id: str + first_name: str + + +JOHN_DOE = Profile( + display_name="John Doe", + work=Work( + start_date="2021-11-01", + manager="1234567890123456789", + work_phone="", + tenure_duration=TenureDuration( + period_iso="P3Y1M27D", + sort_factor=1137, + humanize="3 years, 1 month and 27 days", + ), + reports_to=ReportsTo( + display_name="Jane Smith", + email="j.smith@fakemail.com", + surname="Smith", + first_name="Jane", + id="1234567890123456789", + ), + indirect_reports=3, + site_id=2216118, + department="Sales", + tenure_years=3, + custom_columns=CustomColumns( + column_1689923448119="", + column_1708713324447="456789012", + column_1659977358302="", + ), + is_manager=True, + title="Manager", + site="Tel Aviv, Israel", + direct_reports=3, + ), + company_id=123456, + email="j.doe@fakemail.com", + surname="Doe", + id="7890123456789012345", + first_name="John", +) + +EMILY_CARTER = Profile( + display_name="Emily Carter", + work=Work( + start_date="2022-02-22", + manager="9876543210987654321", + work_phone="", + tenure_duration=TenureDuration( + period_iso="P2Y10M6D", + sort_factor=1026, + humanize="2 years, 10 months and 6 days", + ), + reports_to=ReportsTo( + display_name="Robert Brown", + email="r.brown@fakemail.com", + surname="Brown", + first_name="Robert", + id="9876543210987654321", + ), + indirect_reports=2, + site_id=2216120, + department="Marketing", + tenure_years=3, + custom_columns=CustomColumns( + column_1689923448119="", + column_1708713324447="567890123", + column_1659977358302="", + ), + is_manager=False, + title="Specialist", + site="Kuala Lumpur, Malaysia", + direct_reports=0, + ), + company_id=654321, + email="e.carter@fakemail.com", + surname="Carter", + id="4567890123456789012", + first_name="Emily", +) + + +class ListItem(BaseModel): + id: str + value: str + name: str + archived: bool + children: list # type: ignore + + +class ListStruct(BaseModel): + name: str + values: list[ListItem] + items: list[ListItem] + + +# Lists +WORKING_LOCATIONS = ListStruct( + name="workingLocations", + values=[ + ListItem( + id="onsite", + value="Onsite/hybrid", + name="Onsite/hybrid", + archived=False, + children=[], + ), + ListItem( + id="remote", + value="Remote", + name="Remote", + archived=False, + children=[], + ), + ], + items=[ + ListItem( + id="onsite", + value="Onsite/hybrid", + name="Onsite/hybrid", + archived=False, + children=[], + ), + ListItem( + id="remote", + value="Remote", + name="Remote", + archived=False, + children=[], + ), + ], +) + +COMPLIANCE_CONSENT_STATUSES = ListStruct( + name="complianceConsentStatuses", + values=[ + ListItem( + id="expired", + value="Expired", + name="Expired", + archived=False, + children=[], + ), + ListItem( + id="pending_initial_consent", + value="Pending initial consent", + name="Pending initial consent", + archived=False, + children=[], + ), + ], + items=[ + ListItem( + id="expired", + value="Expired", + name="Expired", + archived=False, + children=[], + ), + ListItem( + id="pending_initial_consent", + value="Pending initial consent", + name="Pending initial consent", + archived=False, + children=[], + ), + ], +) + +TEAMS = ListStruct( + name="teams", + values=[ + ListItem( + id="team1", + value="Engineering", + name="Engineering", + archived=False, + children=[], + ), + ListItem( + id="team2", + value="Marketing", + name="Marketing", + archived=False, + children=[], + ), + ], + items=[ + ListItem( + id="team1", + value="Engineering", + name="Engineering", + archived=False, + children=[], + ), + ListItem( + id="team2", + value="Marketing", + name="Marketing", + archived=False, + children=[], + ), + ], +) + +PROFILES_RESPONSE_RAW = {"employees": [JOHN_DOE.dict(), EMILY_CARTER.dict()]} + +LISTS_RESPONSE_RAW = { + "workingLocations": WORKING_LOCATIONS.dict(), + "complianceConsentStatuses": COMPLIANCE_CONSENT_STATUSES.dict(), + "teams": TEAMS.dict(), +} + +INTEGRATION_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../")) + + +async def assert_on_results(results: Any, kind: str) -> None: + assert len(results) > 0 + resync_results, errors = results + entities = resync_results + assert len(entities) > 0 + if kind == "profile": + assert len(entities) == 2 + assert entities[0] == JOHN_DOE + assert entities[1] == EMILY_CARTER + elif kind == "list": + assert len(entities) == 3 + assert entities[0] == WORKING_LOCATIONS + assert entities[1] == COMPLIANCE_CONSENT_STATUSES + assert entities[2] == TEAMS + else: + pytest.fail(f"unsupported object kind: {kind}") + + +async def test_full_sync_with_http_mock( + get_mocked_ocean_app: Any, + get_mock_ocean_resource_configs: Any, + httpx_mock: HTTPXMock, +) -> None: + httpx_mock.add_response( + url=re.compile(".*/v1/profiles"), json=PROFILES_RESPONSE_RAW + ) + httpx_mock.add_response( + url=re.compile(".*/v1/company/named-lists"), json=LISTS_RESPONSE_RAW + ) + + app = get_mocked_ocean_app() + resource_configs = get_mock_ocean_resource_configs() + + for resource_config in resource_configs: + results = await get_raw_result_on_integration_sync_resource_config( + app, resource_config + ) + await assert_on_results(results, resource_config.kind)