airbyte-source-kyriba 0.1.0__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airbyte_source_kyriba-0.1.3.dist-info/METADATA +110 -0
- airbyte_source_kyriba-0.1.3.dist-info/RECORD +15 -0
- {airbyte_source_kyriba-0.1.0.dist-info → airbyte_source_kyriba-0.1.3.dist-info}/WHEEL +1 -2
- airbyte_source_kyriba-0.1.3.dist-info/entry_points.txt +3 -0
- source_kyriba/schemas/accounts.json +174 -289
- source_kyriba/schemas/bank_balances_eod.json +20 -38
- source_kyriba/schemas/bank_balances_intraday.json +21 -32
- source_kyriba/schemas/cash_balances_eod.json +36 -58
- source_kyriba/schemas/cash_balances_intraday.json +29 -57
- source_kyriba/schemas/cash_flows.json +25 -47
- source_kyriba/schemas/shared/_definitions.json +146 -333
- source_kyriba/source.py +9 -3
- source_kyriba/spec.json +9 -5
- airbyte_source_kyriba-0.1.0.dist-info/METADATA +0 -99
- airbyte_source_kyriba-0.1.0.dist-info/RECORD +0 -31
- airbyte_source_kyriba-0.1.0.dist-info/entry_points.txt +0 -2
- airbyte_source_kyriba-0.1.0.dist-info/top_level.txt +0 -3
- integration_tests/__init__.py +0 -3
- integration_tests/abnormal_state.json +0 -1
- integration_tests/acceptance.py +0 -16
- integration_tests/configured_catalog.json +0 -74
- integration_tests/invalid_config.json +0 -7
- integration_tests/sample_config.json +0 -7
- integration_tests/sample_state.json +0 -1
- unit_tests/__init__.py +0 -3
- unit_tests/test_account_sub_stream.py +0 -37
- unit_tests/test_bank_balances_stream.py +0 -77
- unit_tests/test_cash_balances_stream.py +0 -77
- unit_tests/test_cash_flows.py +0 -100
- unit_tests/test_incremental_streams.py +0 -72
- unit_tests/test_source.py +0 -35
- unit_tests/test_streams.py +0 -121
source_kyriba/source.py
CHANGED
@@ -270,9 +270,15 @@ class SourceKyriba(AbstractSource):
|
|
270
270
|
return f"https://{config['domain']}/gateway"
|
271
271
|
|
272
272
|
def check_connection(self, logger, config) -> Tuple[bool, any]:
|
273
|
-
|
274
|
-
|
275
|
-
|
273
|
+
try:
|
274
|
+
client = KyribaClient(config["username"], config["password"], self.gateway_url(config))
|
275
|
+
client.login()
|
276
|
+
return True, None
|
277
|
+
except Exception as e:
|
278
|
+
if isinstance(e, requests.exceptions.HTTPError) and e.response.status_code == 401:
|
279
|
+
err_message = f"Please check your `username` and `password`. Error: {repr(e)}"
|
280
|
+
return False, err_message
|
281
|
+
return False, repr(e)
|
276
282
|
|
277
283
|
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
|
278
284
|
gateway_url = self.gateway_url(config)
|
source_kyriba/spec.json
CHANGED
@@ -5,32 +5,36 @@
|
|
5
5
|
"title": "Kyriba Spec",
|
6
6
|
"type": "object",
|
7
7
|
"required": ["domain", "username", "password", "start_date"],
|
8
|
-
"additionalProperties":
|
8
|
+
"additionalProperties": true,
|
9
9
|
"properties": {
|
10
10
|
"domain": {
|
11
11
|
"type": "string",
|
12
12
|
"description": "Kyriba domain",
|
13
13
|
"title": "Domain",
|
14
14
|
"examples": ["demo.kyriba.com"],
|
15
|
-
"pattern": "^[a-zA-Z0-9._-]*\\.[a-zA-Z0-9._-]*\\.[a-z]*"
|
15
|
+
"pattern": "^[a-zA-Z0-9._-]*\\.[a-zA-Z0-9._-]*\\.[a-z]*",
|
16
|
+
"order": 2
|
16
17
|
},
|
17
18
|
"username": {
|
18
19
|
"type": "string",
|
19
20
|
"description": "Username to be used in basic auth",
|
20
|
-
"title": "Username"
|
21
|
+
"title": "Username",
|
22
|
+
"order": 0
|
21
23
|
},
|
22
24
|
"password": {
|
23
25
|
"type": "string",
|
24
26
|
"description": "Password to be used in basic auth",
|
25
27
|
"title": "Password",
|
26
|
-
"airbyte_secret": true
|
28
|
+
"airbyte_secret": true,
|
29
|
+
"order": 1
|
27
30
|
},
|
28
31
|
"start_date": {
|
29
32
|
"type": "string",
|
30
33
|
"description": "The date the sync should start from.",
|
31
34
|
"title": "Start Date",
|
32
35
|
"examples": ["2021-01-10"],
|
33
|
-
"pattern": "^\\d{4}\\-(0[1-9]|1[012])\\-(0[1-9]|[12][0-9]|3[01])$"
|
36
|
+
"pattern": "^\\d{4}\\-(0[1-9]|1[012])\\-(0[1-9]|[12][0-9]|3[01])$",
|
37
|
+
"order": 3
|
34
38
|
},
|
35
39
|
"end_date": {
|
36
40
|
"type": "string",
|
@@ -1,99 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: airbyte-source-kyriba
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: Source implementation for Kyriba.
|
5
|
-
Author: Airbyte
|
6
|
-
Author-email: contact@airbyte.io
|
7
|
-
Description-Content-Type: text/markdown
|
8
|
-
Requires-Dist: airbyte-cdk ~=0.1
|
9
|
-
Provides-Extra: tests
|
10
|
-
Requires-Dist: requests-mock ~=1.9.3 ; extra == 'tests'
|
11
|
-
Requires-Dist: pytest ~=6.1 ; extra == 'tests'
|
12
|
-
Requires-Dist: pytest-mock ~=3.6.1 ; extra == 'tests'
|
13
|
-
|
14
|
-
# Kyriba Source
|
15
|
-
|
16
|
-
This is the repository for the Kyriba source connector, written in Python.
|
17
|
-
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/kyriba).
|
18
|
-
|
19
|
-
|
20
|
-
**To iterate on this connector, make sure to complete this prerequisites section.**
|
21
|
-
|
22
|
-
|
23
|
-
From this connector directory, create a virtual environment:
|
24
|
-
```
|
25
|
-
python -m venv .venv
|
26
|
-
```
|
27
|
-
|
28
|
-
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
|
29
|
-
development environment of choice. To activate it from the terminal, run:
|
30
|
-
```
|
31
|
-
source .venv/bin/activate
|
32
|
-
pip install -r requirements.txt
|
33
|
-
pip install '.[tests]'
|
34
|
-
```
|
35
|
-
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
|
36
|
-
|
37
|
-
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
|
38
|
-
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
|
39
|
-
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything
|
40
|
-
should work as you expect.
|
41
|
-
|
42
|
-
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/kyriba)
|
43
|
-
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_kyriba/spec.json` file.
|
44
|
-
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
|
45
|
-
See `integration_tests/sample_config.json` for a sample config file.
|
46
|
-
|
47
|
-
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source kyriba test creds`
|
48
|
-
and place them into `secrets/config.json`.
|
49
|
-
|
50
|
-
```
|
51
|
-
python main.py spec
|
52
|
-
python main.py check --config secrets/config.json
|
53
|
-
python main.py discover --config secrets/config.json
|
54
|
-
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
|
55
|
-
```
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
|
60
|
-
```bash
|
61
|
-
airbyte-ci connectors --name=source-kyriba build
|
62
|
-
```
|
63
|
-
|
64
|
-
An image will be built with the tag `airbyte/source-kyriba:dev`.
|
65
|
-
|
66
|
-
**Via `docker build`:**
|
67
|
-
```bash
|
68
|
-
docker build -t airbyte/source-kyriba:dev .
|
69
|
-
```
|
70
|
-
|
71
|
-
Then run any of the connector commands as follows:
|
72
|
-
```
|
73
|
-
docker run --rm airbyte/source-kyriba:dev spec
|
74
|
-
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-kyriba:dev check --config /secrets/config.json
|
75
|
-
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-kyriba:dev discover --config /secrets/config.json
|
76
|
-
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-kyriba:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
|
77
|
-
```
|
78
|
-
|
79
|
-
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
|
80
|
-
```bash
|
81
|
-
airbyte-ci connectors --name=source-kyriba test
|
82
|
-
```
|
83
|
-
|
84
|
-
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
|
85
|
-
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
|
86
|
-
|
87
|
-
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
|
88
|
-
We split dependencies between two groups, dependencies that are:
|
89
|
-
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
|
90
|
-
* required for the testing need to go to `TEST_REQUIREMENTS` list
|
91
|
-
|
92
|
-
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
|
93
|
-
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-kyriba test`
|
94
|
-
2. Bump the connector version in `metadata.yaml`: increment the `dockerImageTag` value. Please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors).
|
95
|
-
3. Make sure the `metadata.yaml` content is up to date.
|
96
|
-
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/kyriba.md`).
|
97
|
-
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
|
98
|
-
6. Pat yourself on the back for being an awesome contributor.
|
99
|
-
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
|
@@ -1,31 +0,0 @@
|
|
1
|
-
integration_tests/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
|
2
|
-
integration_tests/abnormal_state.json,sha256=rC1HqiQX9YkYOOSudDfYOTXuhzTx5ewhwHHCNSlTpw4,63
|
3
|
-
integration_tests/acceptance.py,sha256=8eU9iSDbmHyufPvAouJGhPMgPAFTCP8IKIKHLm7u5TE,435
|
4
|
-
integration_tests/configured_catalog.json,sha256=gPLZ6c2Ue3mdPu0alht4Eepo1HoxKH_S95oq0sU9agk,2036
|
5
|
-
integration_tests/invalid_config.json,sha256=lijPh7Sdk97-I4koQZdyNvIgmuc_0Lq5ZaEj2EKZpSI,144
|
6
|
-
integration_tests/sample_config.json,sha256=lijPh7Sdk97-I4koQZdyNvIgmuc_0Lq5ZaEj2EKZpSI,144
|
7
|
-
integration_tests/sample_state.json,sha256=m8JPs8MtG-H12oHg5OOqOPLXWTTjJ84Nk3cNGB8ahaQ,63
|
8
|
-
source_kyriba/__init__.py,sha256=jOGOJsttHTq3d1vzU09nqrtOjYfr7jSxNDPpAh6jsdo,124
|
9
|
-
source_kyriba/run.py,sha256=PmVtNsb_MrljQOzs6RfRq1Whxag5nwOc8_bxSTsVrTs,230
|
10
|
-
source_kyriba/source.py,sha256=ykhXb2D0W08Dt_pQN4xIkZIHVxnBcY6YWlujE_7S-6U,11452
|
11
|
-
source_kyriba/spec.json,sha256=uWgri_wB-sQBt_beWL4c7uwTbiDLNM4d0FRDwCLZ4Ng,1434
|
12
|
-
source_kyriba/schemas/accounts.json,sha256=x7X-FKL8zZXv_VArOSt4Woa-Z5AzQVvRRbsDxS0jMa4,15627
|
13
|
-
source_kyriba/schemas/bank_balances_eod.json,sha256=yktaKoJ4-p_ynYYMDF5BIPJMKzLJgM6RAWj2sCg-PF8,1915
|
14
|
-
source_kyriba/schemas/bank_balances_intraday.json,sha256=ewbk-c0vSvkmAHyYpB-aUNEKNU-m2IRopu8Yo_yIwsk,1689
|
15
|
-
source_kyriba/schemas/cash_balances_eod.json,sha256=mAobni2ACSQZvprcpjvQlJ6xbncLZteqhyMkv_SBDCw,3149
|
16
|
-
source_kyriba/schemas/cash_balances_intraday.json,sha256=mAobni2ACSQZvprcpjvQlJ6xbncLZteqhyMkv_SBDCw,3149
|
17
|
-
source_kyriba/schemas/cash_flows.json,sha256=8c9UJNuD1rsFUeexvSDvJZ3tKScXlWLrnegjDmsrfIo,2692
|
18
|
-
source_kyriba/schemas/shared/_definitions.json,sha256=ZI3X6bORMsrL6iHVf9MNdiraBMjeRwEklDzoCQ4JGeE,31124
|
19
|
-
unit_tests/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
|
20
|
-
unit_tests/test_account_sub_stream.py,sha256=G1uqUyxMW0qS3oKlTdNqtUelKHqoqcqscaL7ifvMEVA,1227
|
21
|
-
unit_tests/test_bank_balances_stream.py,sha256=AjgkLKxAUMLlLn5hlEj4h9O0uT7fvLels-vGh7zpKPw,2247
|
22
|
-
unit_tests/test_cash_balances_stream.py,sha256=ePyvBRAKPOoilJFeEsVcvnaRxlKqcfh6gGyIywTdaCM,2247
|
23
|
-
unit_tests/test_cash_flows.py,sha256=OWzRoZNw-OZysUGLu9hP7kIk8JX11ID6wsJKYB7SJVY,2956
|
24
|
-
unit_tests/test_incremental_streams.py,sha256=itMhsi_GS1H7BCoVPxFKCQPvsmSNe8ZhGRG6f00NxSk,2867
|
25
|
-
unit_tests/test_source.py,sha256=9DgaSSp4YLnt0slg38eUnaXwkMyEBn4TjlzE5UnzrXc,809
|
26
|
-
unit_tests/test_streams.py,sha256=A-0wy-LcDAZd9ctdd7lclIO6PgWY7dhWXiiU4QDO4mY,4001
|
27
|
-
airbyte_source_kyriba-0.1.0.dist-info/METADATA,sha256=5iXiBeRx8Xv5OLkqRqEAe-6dnz1onxbdmkCIZ6TF5yc,5379
|
28
|
-
airbyte_source_kyriba-0.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
29
|
-
airbyte_source_kyriba-0.1.0.dist-info/entry_points.txt,sha256=smWDewVsgAlq6sp4uAg8ky1dyttmbePgrmnEdWMxUyQ,56
|
30
|
-
airbyte_source_kyriba-0.1.0.dist-info/top_level.txt,sha256=Kd2MA5n5lkCdEaUZx7WdG56TmA86vrX4xvqXOak2hw0,43
|
31
|
-
airbyte_source_kyriba-0.1.0.dist-info/RECORD,,
|
integration_tests/__init__.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{ "cash_flows": { "updateDateTime": "9999-05-04T18:31:18Z" } }
|
integration_tests/acceptance.py
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
import pytest
|
7
|
-
|
8
|
-
pytest_plugins = ("connector_acceptance_test.plugin",)
|
9
|
-
|
10
|
-
|
11
|
-
@pytest.fixture(scope="session", autouse=True)
|
12
|
-
def connector_setup():
|
13
|
-
"""This fixture is a placeholder for external resources that acceptance test might require."""
|
14
|
-
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
|
15
|
-
yield
|
16
|
-
# TODO: clean up test dependencies
|
@@ -1,74 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"streams": [
|
3
|
-
{
|
4
|
-
"stream": {
|
5
|
-
"name": "bank_balances_intraday",
|
6
|
-
"json_schema": {
|
7
|
-
"$schema": "http://json-schema.org/draft-04/schema"
|
8
|
-
},
|
9
|
-
"supported_sync_modes": ["full_refresh"]
|
10
|
-
},
|
11
|
-
"sync_mode": "full_refresh",
|
12
|
-
"destination_sync_mode": "overwrite"
|
13
|
-
},
|
14
|
-
{
|
15
|
-
"stream": {
|
16
|
-
"name": "cash_balances_intraday",
|
17
|
-
"json_schema": {
|
18
|
-
"$schema": "http://json-schema.org/draft-04/schema"
|
19
|
-
},
|
20
|
-
"supported_sync_modes": ["full_refresh"]
|
21
|
-
},
|
22
|
-
"sync_mode": "full_refresh",
|
23
|
-
"destination_sync_mode": "overwrite"
|
24
|
-
},
|
25
|
-
{
|
26
|
-
"stream": {
|
27
|
-
"name": "accounts",
|
28
|
-
"json_schema": {
|
29
|
-
"$schema": "http://json-schema.org/draft-04/schema"
|
30
|
-
},
|
31
|
-
"supported_sync_modes": ["full_refresh"]
|
32
|
-
},
|
33
|
-
"sync_mode": "full_refresh",
|
34
|
-
"source_defined_primary_key": [["uuid"], ["code"]],
|
35
|
-
"destination_sync_mode": "overwrite"
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"stream": {
|
39
|
-
"name": "cash_flows",
|
40
|
-
"json_schema": {
|
41
|
-
"$schema": "http://json-schema.org/draft-04/schema"
|
42
|
-
},
|
43
|
-
"supported_sync_modes": ["full_refresh", "incremental"],
|
44
|
-
"source_defined_cursor": true,
|
45
|
-
"default_cursor_field": ["updateDateTime"]
|
46
|
-
},
|
47
|
-
"sync_mode": "incremental",
|
48
|
-
"source_defined_primary_key": [["uuid"]],
|
49
|
-
"destination_sync_mode": "append"
|
50
|
-
},
|
51
|
-
{
|
52
|
-
"stream": {
|
53
|
-
"name": "cash_balances_eod",
|
54
|
-
"json_schema": {
|
55
|
-
"$schema": "http://json-schema.org/draft-04/schema"
|
56
|
-
},
|
57
|
-
"supported_sync_modes": ["full_refresh"]
|
58
|
-
},
|
59
|
-
"sync_mode": "full_refresh",
|
60
|
-
"destination_sync_mode": "overwrite"
|
61
|
-
},
|
62
|
-
{
|
63
|
-
"stream": {
|
64
|
-
"name": "bank_balances_eod",
|
65
|
-
"json_schema": {
|
66
|
-
"$schema": "http://json-schema.org/draft-04/schema"
|
67
|
-
},
|
68
|
-
"supported_sync_modes": ["full_refresh"]
|
69
|
-
},
|
70
|
-
"sync_mode": "full_refresh",
|
71
|
-
"destination_sync_mode": "overwrite"
|
72
|
-
}
|
73
|
-
]
|
74
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{ "cash_flows": { "updateDateTime": "2022-05-04T18:31:18Z" } }
|
unit_tests/__init__.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
from unittest.mock import MagicMock
|
6
|
-
|
7
|
-
import pytest
|
8
|
-
import requests
|
9
|
-
from source_kyriba.source import Accounts, AccountSubStream
|
10
|
-
|
11
|
-
from .test_streams import config
|
12
|
-
|
13
|
-
|
14
|
-
@pytest.fixture
|
15
|
-
def patch_base_class(mocker):
|
16
|
-
# Mock abstract methods to enable instantiating abstract class
|
17
|
-
mocker.patch.object(AccountSubStream, "path", "v0/example_endpoint")
|
18
|
-
mocker.patch.object(AccountSubStream, "primary_key", "test_primary_key")
|
19
|
-
mocker.patch.object(AccountSubStream, "__abstractmethods__", set())
|
20
|
-
|
21
|
-
|
22
|
-
def test_get_account_uuids(patch_base_class):
|
23
|
-
stream = AccountSubStream(**config())
|
24
|
-
account_records = [{"uuid": "first"}, {"uuid": "second"}]
|
25
|
-
Accounts.read_records = MagicMock(return_value=account_records)
|
26
|
-
expected = [{"account_uuid": "first"}, {"account_uuid": "second"}]
|
27
|
-
assert stream.get_account_uuids() == expected
|
28
|
-
|
29
|
-
|
30
|
-
def test_parse_response(patch_base_class):
|
31
|
-
stream = AccountSubStream(**config())
|
32
|
-
resp = requests.Response()
|
33
|
-
resp_dict = {"uuid": "uuid"}
|
34
|
-
resp.json = MagicMock(return_value=resp_dict)
|
35
|
-
inputs = {"response": resp}
|
36
|
-
expected = {"uuid": "uuid"}
|
37
|
-
assert next(stream.parse_response(**inputs)) == expected
|
@@ -1,77 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
from datetime import date
|
6
|
-
from unittest.mock import MagicMock
|
7
|
-
|
8
|
-
import pytest
|
9
|
-
from source_kyriba.source import CashBalancesStream
|
10
|
-
|
11
|
-
from .test_streams import config
|
12
|
-
|
13
|
-
|
14
|
-
@pytest.fixture
|
15
|
-
def patch_base_class(mocker):
|
16
|
-
# Mock abstract methods to enable instantiating abstract class
|
17
|
-
mocker.patch.object(CashBalancesStream, "primary_key", "test_primary_key")
|
18
|
-
mocker.patch.object(CashBalancesStream, "__abstractmethods__", set())
|
19
|
-
|
20
|
-
|
21
|
-
def test_stream_slices(patch_base_class):
|
22
|
-
stream = CashBalancesStream(**config())
|
23
|
-
account_uuids = [{"account_uuid": "first"}, {"account_uuid": "second"}]
|
24
|
-
stream.get_account_uuids = MagicMock(return_value=account_uuids)
|
25
|
-
stream.start_date = date(2022, 1, 1)
|
26
|
-
stream.end_date = date(2022, 3, 1)
|
27
|
-
expected = [
|
28
|
-
{
|
29
|
-
"account_uuid": "first",
|
30
|
-
"startDate": "2022-01-01",
|
31
|
-
"endDate": "2022-02-01",
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"account_uuid": "second",
|
35
|
-
"startDate": "2022-01-01",
|
36
|
-
"endDate": "2022-02-01",
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"account_uuid": "first",
|
40
|
-
"startDate": "2022-02-02",
|
41
|
-
"endDate": "2022-03-01",
|
42
|
-
},
|
43
|
-
{
|
44
|
-
"account_uuid": "second",
|
45
|
-
"startDate": "2022-02-02",
|
46
|
-
"endDate": "2022-03-01",
|
47
|
-
},
|
48
|
-
]
|
49
|
-
slices = stream.stream_slices()
|
50
|
-
assert slices == expected
|
51
|
-
|
52
|
-
|
53
|
-
def test_path(patch_base_class):
|
54
|
-
stream = CashBalancesStream(**config())
|
55
|
-
inputs = {"stream_slice": {"account_uuid": "uuid"}}
|
56
|
-
path = stream.path(**inputs)
|
57
|
-
assert path == "cash-balances/accounts/uuid/balances"
|
58
|
-
|
59
|
-
|
60
|
-
def test_request_params(patch_base_class):
|
61
|
-
stream = CashBalancesStream(**config())
|
62
|
-
inputs = {
|
63
|
-
"stream_slice": {"account_uuid": "uuid", "endDate": "2022-02-01", "startDate": "2022-01-01"},
|
64
|
-
"stream_state": {},
|
65
|
-
}
|
66
|
-
stream.intraday = False
|
67
|
-
params = stream.request_params(**inputs)
|
68
|
-
expected = {
|
69
|
-
"endDate": "2022-02-01",
|
70
|
-
"startDate": "2022-01-01",
|
71
|
-
"intraday": False,
|
72
|
-
"actual": True,
|
73
|
-
"estimatedForecasts": False,
|
74
|
-
"confirmedForecasts": False,
|
75
|
-
"dateType": "VALUE",
|
76
|
-
}
|
77
|
-
assert params == expected
|
@@ -1,77 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
from datetime import date
|
6
|
-
from unittest.mock import MagicMock
|
7
|
-
|
8
|
-
import pytest
|
9
|
-
from source_kyriba.source import CashBalancesStream
|
10
|
-
|
11
|
-
from .test_streams import config
|
12
|
-
|
13
|
-
|
14
|
-
@pytest.fixture
|
15
|
-
def patch_base_class(mocker):
|
16
|
-
# Mock abstract methods to enable instantiating abstract class
|
17
|
-
mocker.patch.object(CashBalancesStream, "primary_key", "test_primary_key")
|
18
|
-
mocker.patch.object(CashBalancesStream, "__abstractmethods__", set())
|
19
|
-
|
20
|
-
|
21
|
-
def test_stream_slices(patch_base_class):
|
22
|
-
stream = CashBalancesStream(**config())
|
23
|
-
account_uuids = [{"account_uuid": "first"}, {"account_uuid": "second"}]
|
24
|
-
stream.get_account_uuids = MagicMock(return_value=account_uuids)
|
25
|
-
stream.start_date = date(2022, 1, 1)
|
26
|
-
stream.end_date = date(2022, 3, 1)
|
27
|
-
expected = [
|
28
|
-
{
|
29
|
-
"account_uuid": "first",
|
30
|
-
"startDate": "2022-01-01",
|
31
|
-
"endDate": "2022-02-01",
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"account_uuid": "second",
|
35
|
-
"startDate": "2022-01-01",
|
36
|
-
"endDate": "2022-02-01",
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"account_uuid": "first",
|
40
|
-
"startDate": "2022-02-02",
|
41
|
-
"endDate": "2022-03-01",
|
42
|
-
},
|
43
|
-
{
|
44
|
-
"account_uuid": "second",
|
45
|
-
"startDate": "2022-02-02",
|
46
|
-
"endDate": "2022-03-01",
|
47
|
-
},
|
48
|
-
]
|
49
|
-
slices = stream.stream_slices()
|
50
|
-
assert slices == expected
|
51
|
-
|
52
|
-
|
53
|
-
def test_path(patch_base_class):
|
54
|
-
stream = CashBalancesStream(**config())
|
55
|
-
inputs = {"stream_slice": {"account_uuid": "uuid"}}
|
56
|
-
path = stream.path(**inputs)
|
57
|
-
assert path == "cash-balances/accounts/uuid/balances"
|
58
|
-
|
59
|
-
|
60
|
-
def test_request_params(patch_base_class):
|
61
|
-
stream = CashBalancesStream(**config())
|
62
|
-
inputs = {
|
63
|
-
"stream_slice": {"account_uuid": "uuid", "startDate": "2022-01-01", "endDate": "2022-02-01"},
|
64
|
-
"stream_state": {},
|
65
|
-
}
|
66
|
-
stream.intraday = False
|
67
|
-
params = stream.request_params(**inputs)
|
68
|
-
expected = {
|
69
|
-
"startDate": "2022-01-01",
|
70
|
-
"endDate": "2022-02-01",
|
71
|
-
"intraday": False,
|
72
|
-
"actual": True,
|
73
|
-
"estimatedForecasts": False,
|
74
|
-
"confirmedForecasts": False,
|
75
|
-
"dateType": "VALUE",
|
76
|
-
}
|
77
|
-
assert params == expected
|
unit_tests/test_cash_flows.py
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import date
|
7
|
-
from unittest.mock import MagicMock
|
8
|
-
|
9
|
-
import requests
|
10
|
-
from airbyte_cdk.models import SyncMode
|
11
|
-
from pytest import fixture
|
12
|
-
from source_kyriba.source import CashFlows
|
13
|
-
|
14
|
-
from .test_streams import config
|
15
|
-
|
16
|
-
|
17
|
-
@fixture
|
18
|
-
def patch_base_class(mocker):
|
19
|
-
# Mock abstract methods to enable instantiating abstract class
|
20
|
-
mocker.patch.object(CashFlows, "primary_key", "test_primary_key")
|
21
|
-
mocker.patch.object(CashFlows, "__abstractmethods__", set())
|
22
|
-
|
23
|
-
|
24
|
-
def test_path(patch_base_class):
|
25
|
-
stream = CashFlows(**config())
|
26
|
-
assert stream.path() == "cash-flows"
|
27
|
-
|
28
|
-
|
29
|
-
def test_stream_slices_new(patch_base_class):
|
30
|
-
stream = CashFlows(**config())
|
31
|
-
stream.start_date = date(2021, 1, 1)
|
32
|
-
stream.end_date = date(2021, 1, 3)
|
33
|
-
inputs = {"sync_mode": SyncMode.incremental, "cursor_field": [], "stream_state": {}}
|
34
|
-
expected_stream_slice = [
|
35
|
-
{
|
36
|
-
"startDate": "2021-01-01",
|
37
|
-
"endDate": "2021-01-01",
|
38
|
-
},
|
39
|
-
{
|
40
|
-
"startDate": "2021-01-02",
|
41
|
-
"endDate": "2021-01-02",
|
42
|
-
},
|
43
|
-
{
|
44
|
-
"startDate": "2021-01-03",
|
45
|
-
"endDate": "2021-01-03",
|
46
|
-
},
|
47
|
-
]
|
48
|
-
assert stream.stream_slices(**inputs) == expected_stream_slice
|
49
|
-
|
50
|
-
|
51
|
-
def test_stream_slices_state(patch_base_class):
|
52
|
-
stream = CashFlows(**config())
|
53
|
-
stream.start_date = date.fromisoformat("2021-01-01")
|
54
|
-
stream.end_date = date.fromisoformat("2021-01-03")
|
55
|
-
inputs = {"sync_mode": SyncMode.incremental, "cursor_field": [], "stream_state": {"updateDateTime": "2021-01-02T00:00:00Z"}}
|
56
|
-
expected_stream_slice = [
|
57
|
-
{
|
58
|
-
"startDate": "2021-01-02",
|
59
|
-
"endDate": "2021-01-02",
|
60
|
-
},
|
61
|
-
{
|
62
|
-
"startDate": "2021-01-03",
|
63
|
-
"endDate": "2021-01-03",
|
64
|
-
},
|
65
|
-
]
|
66
|
-
assert stream.stream_slices(**inputs) == expected_stream_slice
|
67
|
-
|
68
|
-
|
69
|
-
def test_all_request_params(patch_base_class):
|
70
|
-
stream = CashFlows(**config())
|
71
|
-
inputs = {
|
72
|
-
"stream_state": {
|
73
|
-
"updateDateTime": "2022-01-01T00:00:00Z",
|
74
|
-
},
|
75
|
-
"stream_slice": {
|
76
|
-
"startDate": "2021-01-01",
|
77
|
-
"endDate": "2022-01-02",
|
78
|
-
},
|
79
|
-
"next_page_token": {
|
80
|
-
"page.offset": 1000,
|
81
|
-
},
|
82
|
-
}
|
83
|
-
expected = {
|
84
|
-
"sort": "updateDateTime",
|
85
|
-
"page.offset": 1000,
|
86
|
-
"filter": "updateDateTime=gt='2022-01-01T00:00:00Z'",
|
87
|
-
"dateType": "UPDATE",
|
88
|
-
"page.limit": 1000,
|
89
|
-
"startDate": "2021-01-01",
|
90
|
-
"endDate": "2022-01-02",
|
91
|
-
}
|
92
|
-
assert stream.request_params(**inputs) == expected
|
93
|
-
|
94
|
-
|
95
|
-
def test_parse_response(patch_base_class):
|
96
|
-
stream = CashFlows(**config())
|
97
|
-
resp = requests.Response()
|
98
|
-
resp_data = {"results": [{"date": {"updateDateTime": "2022-03-01T00:00:00Z"}}]}
|
99
|
-
resp.json = MagicMock(return_value=resp_data)
|
100
|
-
assert next(stream.parse_response(resp)) == {"updateDateTime": "2022-03-01T00:00:00Z"}
|