api-foundry 0.1.2__tar.gz → 0.1.4__tar.gz
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.
Potentially problematic release.
This version of api-foundry might be problematic. Click here for more details.
- api_foundry-0.1.4/.gitignore +11 -0
- {api_foundry-0.1.2/src/api_foundry/api_foundry.egg-info → api_foundry-0.1.4}/PKG-INFO +10 -13
- api_foundry-0.1.4/api_foundry/__init__.py +0 -0
- api_foundry-0.1.4/api_foundry/cloudprints/pulumi/log_group.pv +19 -0
- api_foundry-0.1.4/api_foundry/operation.py +15 -0
- api_foundry-0.1.4/pyproject.toml +45 -0
- api_foundry-0.1.2/PKG-INFO +0 -22
- api_foundry-0.1.2/pyproject.toml +0 -49
- api_foundry-0.1.2/setup.cfg +0 -4
- api_foundry-0.1.2/src/api_foundry/api_foundry.egg-info/SOURCES.txt +0 -58
- api_foundry-0.1.2/src/api_foundry/api_foundry.egg-info/dependency_links.txt +0 -1
- api_foundry-0.1.2/src/api_foundry/api_foundry.egg-info/entry_points.txt +0 -2
- api_foundry-0.1.2/src/api_foundry/api_foundry.egg-info/requires.txt +0 -8
- api_foundry-0.1.2/src/api_foundry/api_foundry.egg-info/top_level.txt +0 -8
- api_foundry-0.1.2/tests/test_adapter.py +0 -42
- api_foundry-0.1.2/tests/test_association_operations.py +0 -199
- api_foundry-0.1.2/tests/test_connection_factory.py +0 -18
- api_foundry-0.1.2/tests/test_custom_operations.py +0 -77
- api_foundry-0.1.2/tests/test_custom_sql.py +0 -125
- api_foundry-0.1.2/tests/test_fixtures.py +0 -74
- api_foundry-0.1.2/tests/test_gateway_adapter.py +0 -79
- api_foundry-0.1.2/tests/test_gateway_spec.py +0 -101
- api_foundry-0.1.2/tests/test_handler.py +0 -60
- api_foundry-0.1.2/tests/test_metadata_operations.py +0 -175
- api_foundry-0.1.2/tests/test_model_factory.py +0 -102
- api_foundry-0.1.2/tests/test_query_operations.py +0 -203
- api_foundry-0.1.2/tests/test_schema_objects_fixtures.py +0 -106
- api_foundry-0.1.2/tests/test_spec_handler.py +0 -96
- api_foundry-0.1.2/tests/test_sql_handler.py +0 -531
- api_foundry-0.1.2/tests/test_sql_insert_handler.py +0 -546
- api_foundry-0.1.2/tests/test_sql_update_handler.py +0 -179
- api_foundry-0.1.2/tests/test_transactional_service.py +0 -324
- {api_foundry-0.1.2 → api_foundry-0.1.4}/LICENSE +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/adapters/adapter.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/adapters/case_change_adapter.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/adapters/gateway_adapter.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/cloudprints/archive_builder.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/cloudprints/aws_cdk/iam_execution_role.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/cloudprints/hash_comparator.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/cloudprints/pulumi/lambda_.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/cloudprints/pulumi/rest_api.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/cloudprints/python_archive_builder.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/connectors/connection.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/connectors/connection_factory.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/connectors/oracle_connector.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/connectors/postgres_connection.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/dao.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/operation_dao.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/sql_custom_query_handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/sql_delete_query_handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/sql_insert_query_handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/sql_query_handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/sql_select_query_handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/sql_subselect_query_handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/dao/sql_update_query_handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/iac/gateway_spec.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/iac/handler.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/iac/pulumi/api_maker.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/scripts/postgres_to_openapi.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/services/service.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/services/transactional_service.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/utils/app_exception.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/utils/logger.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/utils/model_factory.py +0 -0
- {api_foundry-0.1.2/src → api_foundry-0.1.4}/api_foundry/utils/spec_handler.py +0 -0
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: api-foundry
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: The `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs
|
|
5
|
-
Author-email: Daniel Repik <danrepik@icloud.com>
|
|
6
5
|
Project-URL: Documentation, https://github.com/DanRepik/api-foundry
|
|
7
6
|
Project-URL: Source, https://github.com/DanRepik/api-foundry
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
7
|
+
Author-email: Daniel Repik <danrepik@icloud.com>
|
|
8
|
+
License-File: LICENSE
|
|
12
9
|
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
11
|
Requires-Python: >=3.9
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: pyhumps
|
|
16
|
-
Requires-Dist: cryptography
|
|
17
|
-
Requires-Dist: requests
|
|
18
|
-
Requires-Dist: simplejson
|
|
19
|
-
Requires-Dist: pyyaml
|
|
20
12
|
Requires-Dist: boto3
|
|
13
|
+
Requires-Dist: cryptography
|
|
21
14
|
Requires-Dist: pulumi
|
|
22
15
|
Requires-Dist: pulumi-aws
|
|
16
|
+
Requires-Dist: pyhumps
|
|
17
|
+
Requires-Dist: pyyaml
|
|
18
|
+
Requires-Dist: requests
|
|
19
|
+
Requires-Dist: simplejson
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
def log_group(scope: Construct, name: str, retention_in_days: int = 3) -> CloudwatchLogGroup:
|
|
2
|
+
"""
|
|
3
|
+
Creates a CloudWatch log group.
|
|
4
|
+
|
|
5
|
+
Args:
|
|
6
|
+
name (str): The name of the log group.
|
|
7
|
+
retention_in_days (int, optional): Default retention period in days. Defaults to 3 days.
|
|
8
|
+
|
|
9
|
+
Returns:
|
|
10
|
+
CloudwatchLogGroup: The created CloudWatch log group.
|
|
11
|
+
"""
|
|
12
|
+
return CloudwatchLogGroup(
|
|
13
|
+
scope,
|
|
14
|
+
make_id(scope, name),
|
|
15
|
+
name=f"{scope.config.get('environment')}/{scope.config.get('product')}/{scope.config.get('domain')}/{name}",
|
|
16
|
+
retention_in_days=retention_in_days,
|
|
17
|
+
tags=make_tags(scope, name)
|
|
18
|
+
)
|
|
19
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class Operation:
|
|
2
|
+
def __init__(
|
|
3
|
+
self,
|
|
4
|
+
*,
|
|
5
|
+
operation_id: str,
|
|
6
|
+
action: str,
|
|
7
|
+
query_params={},
|
|
8
|
+
store_params={},
|
|
9
|
+
metadata_params={},
|
|
10
|
+
):
|
|
11
|
+
self.operation_id = operation_id
|
|
12
|
+
self.action = action
|
|
13
|
+
self.query_params = query_params
|
|
14
|
+
self.store_params = store_params
|
|
15
|
+
self.metadata_params = metadata_params
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "api-foundry"
|
|
7
|
+
version = "0.1.4"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Daniel Repik", email="danrepik@icloud.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "The `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs"
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3.9",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"pyhumps",
|
|
19
|
+
"cryptography",
|
|
20
|
+
"requests",
|
|
21
|
+
"simplejson",
|
|
22
|
+
"pyyaml",
|
|
23
|
+
"boto3",
|
|
24
|
+
"pulumi",
|
|
25
|
+
"pulumi-aws",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
"Documentation" = "https://github.com/DanRepik/api-foundry"
|
|
30
|
+
"Source" = "https://github.com/DanRepik/api-foundry"
|
|
31
|
+
|
|
32
|
+
[tool.hatch.build.targets.sdist]
|
|
33
|
+
include = ["api_foundry"]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
include = ["api_foundry"]
|
|
37
|
+
|
|
38
|
+
[tool.hatch.metadata.scripts]
|
|
39
|
+
postgres_to_openapi = "api_foundry.scripts.postgres_to_openapi:main"
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
markers = [
|
|
43
|
+
"unit: marks tests as unit tests that do not require a database",
|
|
44
|
+
"integration: marks tests that operate on a real database",
|
|
45
|
+
]
|
api_foundry-0.1.2/PKG-INFO
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: api-foundry
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: The `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs
|
|
5
|
-
Author-email: Daniel Repik <danrepik@icloud.com>
|
|
6
|
-
Project-URL: Documentation, https://github.com/DanRepik/api-foundry
|
|
7
|
-
Project-URL: Source, https://github.com/DanRepik/api-foundry
|
|
8
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.9
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: pyhumps
|
|
16
|
-
Requires-Dist: cryptography
|
|
17
|
-
Requires-Dist: requests
|
|
18
|
-
Requires-Dist: simplejson
|
|
19
|
-
Requires-Dist: pyyaml
|
|
20
|
-
Requires-Dist: boto3
|
|
21
|
-
Requires-Dist: pulumi
|
|
22
|
-
Requires-Dist: pulumi-aws
|
api_foundry-0.1.2/pyproject.toml
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61.0"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
# requires = ["hatchling"]
|
|
5
|
-
# build-backend = "hatchling.build"
|
|
6
|
-
|
|
7
|
-
[project]
|
|
8
|
-
name = "api-foundry"
|
|
9
|
-
version = "0.1.2"
|
|
10
|
-
authors = [
|
|
11
|
-
{ name="Daniel Repik", email="danrepik@icloud.com" },
|
|
12
|
-
]
|
|
13
|
-
dependencies = [
|
|
14
|
-
'pyhumps',
|
|
15
|
-
'cryptography',
|
|
16
|
-
'requests',
|
|
17
|
-
'simplejson',
|
|
18
|
-
'pyyaml',
|
|
19
|
-
'boto3',
|
|
20
|
-
'pulumi',
|
|
21
|
-
'pulumi-aws'
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
description = "The `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs"
|
|
25
|
-
requires-python = ">=3.9"
|
|
26
|
-
classifiers = [
|
|
27
|
-
"Programming Language :: Python :: 3.9",
|
|
28
|
-
"Programming Language :: Python :: 3.10",
|
|
29
|
-
"Programming Language :: Python :: 3.11",
|
|
30
|
-
"Programming Language :: Python :: 3.12",
|
|
31
|
-
"Operating System :: OS Independent",
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
[project.urls]
|
|
35
|
-
Documentation = "https://github.com/DanRepik/api-foundry"
|
|
36
|
-
Source = "https://github.com/DanRepik/api-foundry"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
[project.scripts]
|
|
40
|
-
postgres_to_openapi = "api_foundry.scripts.postgres_to_openapi:main"
|
|
41
|
-
|
|
42
|
-
[tool.setuptools.packages.find]
|
|
43
|
-
where = ["src/api_foundry"]
|
|
44
|
-
|
|
45
|
-
[tool.pytest.ini_options]
|
|
46
|
-
markers = [
|
|
47
|
-
"unit: marks tests as unit tests that do not require a database",
|
|
48
|
-
"integration: marks tests that operate on real database"
|
|
49
|
-
]
|
api_foundry-0.1.2/setup.cfg
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
pyproject.toml
|
|
3
|
-
src/api_foundry/adapters/adapter.py
|
|
4
|
-
src/api_foundry/adapters/case_change_adapter.py
|
|
5
|
-
src/api_foundry/adapters/gateway_adapter.py
|
|
6
|
-
src/api_foundry/api_foundry.egg-info/PKG-INFO
|
|
7
|
-
src/api_foundry/api_foundry.egg-info/SOURCES.txt
|
|
8
|
-
src/api_foundry/api_foundry.egg-info/dependency_links.txt
|
|
9
|
-
src/api_foundry/api_foundry.egg-info/entry_points.txt
|
|
10
|
-
src/api_foundry/api_foundry.egg-info/requires.txt
|
|
11
|
-
src/api_foundry/api_foundry.egg-info/top_level.txt
|
|
12
|
-
src/api_foundry/cloudprints/archive_builder.py
|
|
13
|
-
src/api_foundry/cloudprints/hash_comparator.py
|
|
14
|
-
src/api_foundry/cloudprints/python_archive_builder.py
|
|
15
|
-
src/api_foundry/cloudprints/aws_cdk/iam_execution_role.py
|
|
16
|
-
src/api_foundry/cloudprints/pulumi/lambda_.py
|
|
17
|
-
src/api_foundry/cloudprints/pulumi/rest_api.py
|
|
18
|
-
src/api_foundry/connectors/connection.py
|
|
19
|
-
src/api_foundry/connectors/connection_factory.py
|
|
20
|
-
src/api_foundry/connectors/oracle_connector.py
|
|
21
|
-
src/api_foundry/connectors/postgres_connection.py
|
|
22
|
-
src/api_foundry/dao/dao.py
|
|
23
|
-
src/api_foundry/dao/operation_dao.py
|
|
24
|
-
src/api_foundry/dao/sql_custom_query_handler.py
|
|
25
|
-
src/api_foundry/dao/sql_delete_query_handler.py
|
|
26
|
-
src/api_foundry/dao/sql_insert_query_handler.py
|
|
27
|
-
src/api_foundry/dao/sql_query_handler.py
|
|
28
|
-
src/api_foundry/dao/sql_select_query_handler.py
|
|
29
|
-
src/api_foundry/dao/sql_subselect_query_handler.py
|
|
30
|
-
src/api_foundry/dao/sql_update_query_handler.py
|
|
31
|
-
src/api_foundry/iac/gateway_spec.py
|
|
32
|
-
src/api_foundry/iac/handler.py
|
|
33
|
-
src/api_foundry/iac/pulumi/api_maker.py
|
|
34
|
-
src/api_foundry/scripts/postgres_to_openapi.py
|
|
35
|
-
src/api_foundry/services/service.py
|
|
36
|
-
src/api_foundry/services/transactional_service.py
|
|
37
|
-
src/api_foundry/utils/app_exception.py
|
|
38
|
-
src/api_foundry/utils/logger.py
|
|
39
|
-
src/api_foundry/utils/model_factory.py
|
|
40
|
-
src/api_foundry/utils/spec_handler.py
|
|
41
|
-
tests/test_adapter.py
|
|
42
|
-
tests/test_association_operations.py
|
|
43
|
-
tests/test_connection_factory.py
|
|
44
|
-
tests/test_custom_operations.py
|
|
45
|
-
tests/test_custom_sql.py
|
|
46
|
-
tests/test_fixtures.py
|
|
47
|
-
tests/test_gateway_adapter.py
|
|
48
|
-
tests/test_gateway_spec.py
|
|
49
|
-
tests/test_handler.py
|
|
50
|
-
tests/test_metadata_operations.py
|
|
51
|
-
tests/test_model_factory.py
|
|
52
|
-
tests/test_query_operations.py
|
|
53
|
-
tests/test_schema_objects_fixtures.py
|
|
54
|
-
tests/test_spec_handler.py
|
|
55
|
-
tests/test_sql_handler.py
|
|
56
|
-
tests/test_sql_insert_handler.py
|
|
57
|
-
tests/test_sql_update_handler.py
|
|
58
|
-
tests/test_transactional_service.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from api_foundry.services.service import Service
|
|
2
|
-
from api_foundry.adapters.adapter import Adapter
|
|
3
|
-
from api_foundry.operation import Operation
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class MockService(Service):
|
|
7
|
-
def execute(self, operation):
|
|
8
|
-
# Simulating service execution and returning dummy result
|
|
9
|
-
assert operation.operation_id == "entity"
|
|
10
|
-
assert operation.action == "action"
|
|
11
|
-
assert operation.query_params == {"query": "query"}
|
|
12
|
-
return [{"key": "value"}]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# Mock adapter provides provides abstract functions for Adapter class
|
|
16
|
-
class MockAdapter(Adapter):
|
|
17
|
-
def marshal(self, result: list[dict]):
|
|
18
|
-
return result
|
|
19
|
-
|
|
20
|
-
def unmarshal(self, event):
|
|
21
|
-
return Operation(
|
|
22
|
-
operation_id="entity",
|
|
23
|
-
action="action",
|
|
24
|
-
store_params={"store": "store"},
|
|
25
|
-
query_params={"query": "query"},
|
|
26
|
-
metadata_params={"metadata": "metadata"},
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class TestAdapter:
|
|
31
|
-
def test_stub(self):
|
|
32
|
-
assert True
|
|
33
|
-
|
|
34
|
-
def test_adapter(self):
|
|
35
|
-
mock_service = MockService()
|
|
36
|
-
mock_adapter = MockAdapter(mock_service)
|
|
37
|
-
|
|
38
|
-
# Calling the process_event method
|
|
39
|
-
result = mock_adapter.process_event(event={})
|
|
40
|
-
|
|
41
|
-
# Asserting the result
|
|
42
|
-
assert result == [{"key": "value"}]
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from api_foundry.utils.app_exception import ApplicationException
|
|
4
|
-
from api_foundry.utils.logger import logger
|
|
5
|
-
from api_foundry.operation import Operation
|
|
6
|
-
from api_foundry.services.transactional_service import TransactionalService
|
|
7
|
-
|
|
8
|
-
from test_fixtures import load_model, db_secrets # noqa F401
|
|
9
|
-
|
|
10
|
-
log = logger(__name__)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@pytest.mark.integration
|
|
14
|
-
class TestAssociationOperations:
|
|
15
|
-
def test_object_property(self, load_model, db_secrets): # noqa F811
|
|
16
|
-
result = TransactionalService().execute(
|
|
17
|
-
Operation(
|
|
18
|
-
operation_id="invoice",
|
|
19
|
-
action="read",
|
|
20
|
-
query_params={"invoice_id": 5},
|
|
21
|
-
metadata_params={"properties": ".* customer:.*"},
|
|
22
|
-
)
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
log.debug(f"len: {len(result)}")
|
|
26
|
-
invoice = result[0]
|
|
27
|
-
log.debug(f"invoice: {invoice}")
|
|
28
|
-
|
|
29
|
-
assert invoice["customer"]
|
|
30
|
-
assert invoice["customer_id"] == invoice["customer"]["customer_id"]
|
|
31
|
-
assert invoice["customer"]["city"] == "Boston"
|
|
32
|
-
|
|
33
|
-
def test_invalid_object_property(self, load_model, db_secrets): # noqa F811
|
|
34
|
-
try:
|
|
35
|
-
TransactionalService().execute(
|
|
36
|
-
Operation(
|
|
37
|
-
operation_id="invoice",
|
|
38
|
-
action="read",
|
|
39
|
-
query_params={"invoice_id": 5},
|
|
40
|
-
metadata_params={"properties": ".* custom:.*"},
|
|
41
|
-
)
|
|
42
|
-
)
|
|
43
|
-
assert False, "Missing exception"
|
|
44
|
-
except ApplicationException as ae:
|
|
45
|
-
assert ae.status_code == 400
|
|
46
|
-
assert (
|
|
47
|
-
ae.message
|
|
48
|
-
== "Bad object association: invoice does not have a custom property"
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
def test_object_property_criteria(self, load_model, db_secrets): # noqa F811
|
|
52
|
-
result = TransactionalService().execute(
|
|
53
|
-
Operation(
|
|
54
|
-
operation_id="invoice",
|
|
55
|
-
action="read",
|
|
56
|
-
query_params={"customer.phone": "+420 2 4172 5555"},
|
|
57
|
-
)
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
log.debug(f"len: {len(result)}")
|
|
61
|
-
assert len(result) == 7
|
|
62
|
-
invoice = result[3]
|
|
63
|
-
log.debug(f"invoice: {invoice}")
|
|
64
|
-
|
|
65
|
-
assert "customer" not in invoice
|
|
66
|
-
assert invoice["customer_id"] == 5
|
|
67
|
-
assert invoice["billing_city"] == "Prague"
|
|
68
|
-
|
|
69
|
-
def test_invalid_object_property_criteria_1(
|
|
70
|
-
self, load_model, db_secrets # noqa F811
|
|
71
|
-
):
|
|
72
|
-
try:
|
|
73
|
-
TransactionalService().execute(
|
|
74
|
-
Operation(
|
|
75
|
-
operation_id="invoice",
|
|
76
|
-
action="read",
|
|
77
|
-
query_params={"custom.customer_id": 5},
|
|
78
|
-
)
|
|
79
|
-
)
|
|
80
|
-
assert False, "Missing exception"
|
|
81
|
-
except ApplicationException as ae:
|
|
82
|
-
assert ae.status_code == 400
|
|
83
|
-
assert (
|
|
84
|
-
ae.message
|
|
85
|
-
== "Invalid selection property invoice does not have a property custom"
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
def test_invalid_object_property_criteria_2(
|
|
89
|
-
self, load_model, db_secrets # noqa F811
|
|
90
|
-
):
|
|
91
|
-
try:
|
|
92
|
-
TransactionalService().execute(
|
|
93
|
-
Operation(
|
|
94
|
-
operation_id="invoice",
|
|
95
|
-
action="read",
|
|
96
|
-
query_params={"custom.custom_id": 5},
|
|
97
|
-
)
|
|
98
|
-
)
|
|
99
|
-
assert False, "Missing exception"
|
|
100
|
-
except ApplicationException as ae:
|
|
101
|
-
assert ae.status_code == 400
|
|
102
|
-
assert (
|
|
103
|
-
ae.message
|
|
104
|
-
== "Invalid selection property invoice does not have a property custom"
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
def test_array_property(self, load_model, db_secrets): # noqa F811
|
|
108
|
-
result = TransactionalService().execute(
|
|
109
|
-
Operation(
|
|
110
|
-
operation_id="invoice",
|
|
111
|
-
action="read",
|
|
112
|
-
query_params={"invoice_id": 5},
|
|
113
|
-
metadata_params={"properties": ".* invoice_line_items:.*"},
|
|
114
|
-
)
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
log.debug(f"len: {len(result)}")
|
|
118
|
-
invoice = result[0]
|
|
119
|
-
log.debug(f"invoice: {invoice}")
|
|
120
|
-
log.debug(f"line_item: {invoice['invoice_line_items'][0]}")
|
|
121
|
-
|
|
122
|
-
assert invoice["invoice_line_items"]
|
|
123
|
-
assert invoice["invoice_id"] == invoice["invoice_line_items"][0]["invoice_id"]
|
|
124
|
-
assert invoice["invoice_line_items"][0]["invoice_id"] == 5
|
|
125
|
-
assert invoice["invoice_line_items"][0]["track_id"] == 99
|
|
126
|
-
|
|
127
|
-
def test_array_property_criteria(self, load_model, db_secrets): # noqa F811
|
|
128
|
-
result = TransactionalService().execute(
|
|
129
|
-
Operation(
|
|
130
|
-
operation_id="invoice",
|
|
131
|
-
action="read",
|
|
132
|
-
query_params={"invoice_line_items.track_id": 298},
|
|
133
|
-
)
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
log.debug(f"len: {len(result)}")
|
|
137
|
-
assert len(result) == 2
|
|
138
|
-
invoice = result[0]
|
|
139
|
-
log.debug(f"invoice: {invoice}")
|
|
140
|
-
|
|
141
|
-
assert "customer" not in invoice
|
|
142
|
-
assert result[0]["billing_country"] in ["United Kingdom", "Brazil"]
|
|
143
|
-
assert result[1]["billing_country"] in ["United Kingdom", "Brazil"]
|
|
144
|
-
|
|
145
|
-
def test_invalid_array_property(self, load_model, db_secrets): # noqa F811
|
|
146
|
-
try:
|
|
147
|
-
TransactionalService().execute(
|
|
148
|
-
Operation(
|
|
149
|
-
operation_id="invoice",
|
|
150
|
-
action="read",
|
|
151
|
-
query_params={"invoice_id": 5},
|
|
152
|
-
metadata_params={"properties": ".* lint_items:.*"},
|
|
153
|
-
)
|
|
154
|
-
)
|
|
155
|
-
assert False, "Missing exception"
|
|
156
|
-
except ApplicationException as ae:
|
|
157
|
-
assert ae.status_code == 400
|
|
158
|
-
assert (
|
|
159
|
-
ae.message
|
|
160
|
-
== "Bad object association: invoice does not have a lint_items property"
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
def test_invalid_array_property_criteria_1(
|
|
164
|
-
self, load_model, db_secrets # noqa F811
|
|
165
|
-
):
|
|
166
|
-
try:
|
|
167
|
-
TransactionalService().execute(
|
|
168
|
-
Operation(
|
|
169
|
-
operation_id="invoice",
|
|
170
|
-
action="read",
|
|
171
|
-
query_params={"line_itms.line_item_id": 5},
|
|
172
|
-
)
|
|
173
|
-
)
|
|
174
|
-
assert False, "Missing exception"
|
|
175
|
-
except ApplicationException as ae:
|
|
176
|
-
assert ae.status_code == 400
|
|
177
|
-
assert (
|
|
178
|
-
ae.message
|
|
179
|
-
== "Invalid selection property invoice does not have a property line_itms" # noqa E501
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
def test_invalid_array_property_criteria_2(
|
|
183
|
-
self, load_model, db_secrets # noqa F811
|
|
184
|
-
):
|
|
185
|
-
try:
|
|
186
|
-
TransactionalService().execute(
|
|
187
|
-
Operation(
|
|
188
|
-
operation_id="invoice",
|
|
189
|
-
action="read",
|
|
190
|
-
query_params={"line_items.lint_item_id": 5},
|
|
191
|
-
)
|
|
192
|
-
)
|
|
193
|
-
assert False, "Missing exception"
|
|
194
|
-
except ApplicationException as ae:
|
|
195
|
-
assert ae.status_code == 400
|
|
196
|
-
assert (
|
|
197
|
-
ae.message
|
|
198
|
-
== "Invalid selection property invoice does not have a property line_items" # noqa E501
|
|
199
|
-
)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from api_foundry.connectors.connection_factory import connection_factory
|
|
4
|
-
from api_foundry.utils.logger import logger
|
|
5
|
-
|
|
6
|
-
from test_fixtures import db_secrets
|
|
7
|
-
|
|
8
|
-
log = logger(__name__)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@pytest.mark.integration
|
|
12
|
-
class TestPostgresConnection:
|
|
13
|
-
def test_postgres_connection(self, db_secrets):
|
|
14
|
-
connection = connection_factory.get_connection("chinook")
|
|
15
|
-
|
|
16
|
-
log.info(f"connection: {connection}")
|
|
17
|
-
|
|
18
|
-
assert connection is not None
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from api_foundry.utils.app_exception import ApplicationException
|
|
4
|
-
from api_foundry.utils.logger import logger
|
|
5
|
-
from api_foundry.operation import Operation
|
|
6
|
-
from api_foundry.services.transactional_service import TransactionalService
|
|
7
|
-
|
|
8
|
-
from test_fixtures import load_model, db_secrets # noqa F401
|
|
9
|
-
|
|
10
|
-
log = logger(__name__)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@pytest.mark.integration
|
|
14
|
-
class TestCustomOperations:
|
|
15
|
-
def test_top_albums(self, load_model, db_secrets): # noqa F811
|
|
16
|
-
result = TransactionalService().execute(
|
|
17
|
-
Operation(
|
|
18
|
-
operation_id="top_selling_albums",
|
|
19
|
-
action="read",
|
|
20
|
-
query_params={
|
|
21
|
-
"start": "2021-03-01T00:00:00",
|
|
22
|
-
"end": "2021-04-07T00:00:00",
|
|
23
|
-
},
|
|
24
|
-
)
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
log.debug(f"result: {result}")
|
|
28
|
-
log.debug(f"len: {len(result)}")
|
|
29
|
-
assert len(result) == 10
|
|
30
|
-
|
|
31
|
-
assert result[0] == {
|
|
32
|
-
"album_id": 55,
|
|
33
|
-
"album_title": "Chronicle, Vol. 2",
|
|
34
|
-
"total_sold": 9,
|
|
35
|
-
}
|
|
36
|
-
assert result[1] == {
|
|
37
|
-
"album_id": 39,
|
|
38
|
-
"album_title": "International Superhits",
|
|
39
|
-
"total_sold": 8,
|
|
40
|
-
}
|
|
41
|
-
assert result[4] == {
|
|
42
|
-
"album_id": 51,
|
|
43
|
-
"album_title": "Up An' Atom",
|
|
44
|
-
"total_sold": 3,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
def test_top_albums_rename(self, load_model, db_secrets): # noqa F811
|
|
48
|
-
result = TransactionalService().execute(
|
|
49
|
-
Operation(
|
|
50
|
-
operation_id="top_selling_albums_rename",
|
|
51
|
-
action="read",
|
|
52
|
-
query_params={
|
|
53
|
-
"start": "2021-03-01T00:00:00",
|
|
54
|
-
"end": "2021-04-07T00:00:00",
|
|
55
|
-
},
|
|
56
|
-
)
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
log.debug(f"result: {result}")
|
|
60
|
-
log.debug(f"len: {len(result)}")
|
|
61
|
-
assert len(result) == 10
|
|
62
|
-
|
|
63
|
-
assert result[0] == {
|
|
64
|
-
"album_id": 55,
|
|
65
|
-
"album_title": "Chronicle, Vol. 2",
|
|
66
|
-
"total_sold": 9,
|
|
67
|
-
}
|
|
68
|
-
assert result[1] == {
|
|
69
|
-
"album_id": 39,
|
|
70
|
-
"album_title": "International Superhits",
|
|
71
|
-
"total_sold": 8,
|
|
72
|
-
}
|
|
73
|
-
assert result[4] == {
|
|
74
|
-
"album_id": 51,
|
|
75
|
-
"album_title": "Up An' Atom",
|
|
76
|
-
"total_sold": 3,
|
|
77
|
-
}
|