fixturify 0.1.9__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.
- fixturify-0.1.9/.github/workflows/publish.yml +40 -0
- fixturify-0.1.9/.gitignore +210 -0
- fixturify-0.1.9/PKG-INFO +122 -0
- fixturify-0.1.9/README.md +99 -0
- fixturify-0.1.9/docker-compose.yml +48 -0
- fixturify-0.1.9/docs/http.md +189 -0
- fixturify-0.1.9/docs/json_assert.md +180 -0
- fixturify-0.1.9/docs/object_mapper.md +258 -0
- fixturify-0.1.9/docs/read.md +123 -0
- fixturify-0.1.9/docs/sql.md +129 -0
- fixturify-0.1.9/fixturify/__init__.py +21 -0
- fixturify-0.1.9/fixturify/_utils/__init__.py +7 -0
- fixturify-0.1.9/fixturify/_utils/_constants.py +10 -0
- fixturify-0.1.9/fixturify/_utils/_fixture_discovery.py +165 -0
- fixturify-0.1.9/fixturify/_utils/_path_resolver.py +135 -0
- fixturify-0.1.9/fixturify/http_d/__init__.py +80 -0
- fixturify-0.1.9/fixturify/http_d/_config.py +214 -0
- fixturify-0.1.9/fixturify/http_d/_decorator.py +267 -0
- fixturify-0.1.9/fixturify/http_d/_exceptions.py +153 -0
- fixturify-0.1.9/fixturify/http_d/_fixture_discovery.py +33 -0
- fixturify-0.1.9/fixturify/http_d/_matcher.py +372 -0
- fixturify-0.1.9/fixturify/http_d/_mock_context.py +154 -0
- fixturify-0.1.9/fixturify/http_d/_models.py +205 -0
- fixturify-0.1.9/fixturify/http_d/_patcher.py +524 -0
- fixturify-0.1.9/fixturify/http_d/_player.py +222 -0
- fixturify-0.1.9/fixturify/http_d/_recorder.py +1350 -0
- fixturify-0.1.9/fixturify/http_d/_stubs/__init__.py +8 -0
- fixturify-0.1.9/fixturify/http_d/_stubs/_aiohttp.py +220 -0
- fixturify-0.1.9/fixturify/http_d/_stubs/_connection.py +478 -0
- fixturify-0.1.9/fixturify/http_d/_stubs/_httpcore.py +269 -0
- fixturify-0.1.9/fixturify/http_d/_stubs/_tornado.py +95 -0
- fixturify-0.1.9/fixturify/http_d/_utils.py +194 -0
- fixturify-0.1.9/fixturify/json_assert/__init__.py +13 -0
- fixturify-0.1.9/fixturify/json_assert/_actual_saver.py +67 -0
- fixturify-0.1.9/fixturify/json_assert/_assert.py +173 -0
- fixturify-0.1.9/fixturify/json_assert/_comparator.py +183 -0
- fixturify-0.1.9/fixturify/json_assert/_diff_formatter.py +265 -0
- fixturify-0.1.9/fixturify/json_assert/_normalizer.py +83 -0
- fixturify-0.1.9/fixturify/object_mapper/__init__.py +5 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/__init__.py +19 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/_base.py +186 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/_dataclass.py +52 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/_plain.py +55 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/_pydantic_v1.py +38 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/_pydantic_v2.py +41 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/_sqlalchemy.py +72 -0
- fixturify-0.1.9/fixturify/object_mapper/_deserializers/_sqlmodel.py +43 -0
- fixturify-0.1.9/fixturify/object_mapper/_detectors/__init__.py +5 -0
- fixturify-0.1.9/fixturify/object_mapper/_detectors/_type_detector.py +186 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/__init__.py +19 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/_base.py +260 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/_dataclass.py +55 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/_plain.py +49 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/_pydantic_v1.py +49 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/_pydantic_v2.py +49 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/_sqlalchemy.py +70 -0
- fixturify-0.1.9/fixturify/object_mapper/_serializers/_sqlmodel.py +54 -0
- fixturify-0.1.9/fixturify/object_mapper/mapper.py +256 -0
- fixturify-0.1.9/fixturify/read_d/__init__.py +5 -0
- fixturify-0.1.9/fixturify/read_d/_decorator.py +193 -0
- fixturify-0.1.9/fixturify/read_d/_fixture_loader.py +88 -0
- fixturify-0.1.9/fixturify/sql_d/__init__.py +7 -0
- fixturify-0.1.9/fixturify/sql_d/_config.py +30 -0
- fixturify-0.1.9/fixturify/sql_d/_decorator.py +373 -0
- fixturify-0.1.9/fixturify/sql_d/_driver_registry.py +133 -0
- fixturify-0.1.9/fixturify/sql_d/_executor.py +82 -0
- fixturify-0.1.9/fixturify/sql_d/_fixture_discovery.py +55 -0
- fixturify-0.1.9/fixturify/sql_d/_phase.py +10 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/__init__.py +11 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_aiomysql.py +63 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_aiosqlite.py +29 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_asyncpg.py +34 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_base.py +118 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_mysql.py +70 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_psycopg.py +35 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_psycopg2.py +40 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_registry.py +109 -0
- fixturify-0.1.9/fixturify/sql_d/_strategies/_sqlite.py +33 -0
- fixturify-0.1.9/pyproject.toml +66 -0
- fixturify-0.1.9/tests/__init__.py +1 -0
- fixturify-0.1.9/tests/test_http/__init__.py +1 -0
- fixturify-0.1.9/tests/test_http/fixtures/__files/response_1_4678e16e.json +0 -0
- fixturify-0.1.9/tests/test_http/fixtures/aiohttp_get_all_objects.json +134 -0
- fixturify-0.1.9/tests/test_http/fixtures/aiohttp_get_single_object.json +35 -0
- fixturify-0.1.9/tests/test_http/fixtures/aiohttp_multiple_requests.json +94 -0
- fixturify-0.1.9/tests/test_http/fixtures/aiohttp_post_object.json +35 -0
- fixturify-0.1.9/tests/test_http/fixtures/aiohttp_read_text.json +35 -0
- fixturify-0.1.9/tests/test_http/fixtures/aiohttp_with_config.json +37 -0
- fixturify-0.1.9/tests/test_http/fixtures/boto3_localstack_s3.json +54 -0
- fixturify-0.1.9/tests/test_http/fixtures/boto3_localstack_s3_objects.json +81 -0
- fixturify-0.1.9/tests/test_http/fixtures/boto3_localstack_sts.json +24 -0
- fixturify-0.1.9/tests/test_http/fixtures/boto3_s3_list_buckets.json +28 -0
- fixturify-0.1.9/tests/test_http/fixtures/boto3_sts_get_caller_identity.json +24 -0
- fixturify-0.1.9/tests/test_http/fixtures/fixture_config_test.json +38 -0
- fixturify-0.1.9/tests/test_http/fixtures/http_client_get_all_objects.json +133 -0
- fixturify-0.1.9/tests/test_http/fixtures/http_client_get_single_object.json +34 -0
- fixturify-0.1.9/tests/test_http/fixtures/http_client_http_connection.json +3 -0
- fixturify-0.1.9/tests/test_http/fixtures/http_client_post_object.json +41 -0
- fixturify-0.1.9/tests/test_http/fixtures/http_client_sequential.json +61 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpcore_async_get_single.json +34 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpcore_get_single_object.json +34 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpcore_post_object.json +41 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpcore_via_httpx.json +37 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpcore_via_httpx_async.json +37 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpcore_with_config.json +36 -0
- fixturify-0.1.9/tests/test_http/fixtures/httplib2_get_all_objects.json +136 -0
- fixturify-0.1.9/tests/test_http/fixtures/httplib2_get_single_object.json +37 -0
- fixturify-0.1.9/tests/test_http/fixtures/httplib2_post_object.json +43 -0
- fixturify-0.1.9/tests/test_http/fixtures/httplib2_sequential.json +67 -0
- fixturify-0.1.9/tests/test_http/fixtures/httplib2_with_config.json +32 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpx_async_get_all.json +136 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpx_async_get_single.json +37 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpx_async_multiple.json +100 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpx_sync_get_all.json +136 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpx_sync_get_single.json +39 -0
- fixturify-0.1.9/tests/test_http/fixtures/httpx_sync_post.json +46 -0
- fixturify-0.1.9/tests/test_http/fixtures/mixed_clients.json +67 -0
- fixturify-0.1.9/tests/test_http/fixtures/multi_client_async.json +185 -0
- fixturify-0.1.9/tests/test_http/fixtures/multi_client_playback_order.json +187 -0
- fixturify-0.1.9/tests/test_http/fixtures/multi_client_post_requests.json +154 -0
- fixturify-0.1.9/tests/test_http/fixtures/multi_client_sequential.json +319 -0
- fixturify-0.1.9/tests/test_http/fixtures/multi_client_sync.json +290 -0
- fixturify-0.1.9/tests/test_http/fixtures/multi_client_with_config.json +128 -0
- fixturify-0.1.9/tests/test_http/fixtures/multi_client_with_urllib3.json +151 -0
- fixturify-0.1.9/tests/test_http/fixtures/requests_get_all_objects.json +136 -0
- fixturify-0.1.9/tests/test_http/fixtures/requests_get_multiple_objects.json +54 -0
- fixturify-0.1.9/tests/test_http/fixtures/requests_get_single_object.json +37 -0
- fixturify-0.1.9/tests/test_http/fixtures/requests_post_object.json +46 -0
- fixturify-0.1.9/tests/test_http/fixtures/requests_sequential_calls.json +199 -0
- fixturify-0.1.9/tests/test_http/fixtures/requests_with_config.json +38 -0
- fixturify-0.1.9/tests/test_http/fixtures/tornado_async_get_all_objects.json +134 -0
- fixturify-0.1.9/tests/test_http/fixtures/tornado_async_get_single_object.json +35 -0
- fixturify-0.1.9/tests/test_http/fixtures/tornado_async_multiple.json +94 -0
- fixturify-0.1.9/tests/test_http/fixtures/tornado_sync_get_all_objects.json +134 -0
- fixturify-0.1.9/tests/test_http/fixtures/tornado_sync_get_single_object.json +30 -0
- fixturify-0.1.9/tests/test_http/fixtures/tornado_sync_post_object.json +37 -0
- fixturify-0.1.9/tests/test_http/fixtures/tornado_with_config.json +32 -0
- fixturify-0.1.9/tests/test_http/fixtures/urllib3_get_all_objects.json +133 -0
- fixturify-0.1.9/tests/test_http/fixtures/urllib3_get_single_object.json +34 -0
- fixturify-0.1.9/tests/test_http/fixtures/urllib3_poolmanager.json +34 -0
- fixturify-0.1.9/tests/test_http/fixtures/urllib3_post_object.json +41 -0
- fixturify-0.1.9/tests/test_http/fixtures/urllib3_via_requests.json +37 -0
- fixturify-0.1.9/tests/test_http/test_aiohttp_client.py +129 -0
- fixturify-0.1.9/tests/test_http/test_boto3_client.py +221 -0
- fixturify-0.1.9/tests/test_http/test_config.py +221 -0
- fixturify-0.1.9/tests/test_http/test_decorator.py +359 -0
- fixturify-0.1.9/tests/test_http/test_fixture_discovery.py +484 -0
- fixturify-0.1.9/tests/test_http/test_http_client.py +114 -0
- fixturify-0.1.9/tests/test_http/test_httpcore_client.py +156 -0
- fixturify-0.1.9/tests/test_http/test_httplib2_client.py +123 -0
- fixturify-0.1.9/tests/test_http/test_integration.py +376 -0
- fixturify-0.1.9/tests/test_http/test_matcher.py +479 -0
- fixturify-0.1.9/tests/test_http/test_matching.py +1047 -0
- fixturify-0.1.9/tests/test_http/test_models.py +278 -0
- fixturify-0.1.9/tests/test_http/test_multi_client_integration.py +252 -0
- fixturify-0.1.9/tests/test_http/test_player.py +344 -0
- fixturify-0.1.9/tests/test_http/test_recorder.py +287 -0
- fixturify-0.1.9/tests/test_http/test_tornado_client.py +177 -0
- fixturify-0.1.9/tests/test_http/test_urllib3_client.py +115 -0
- fixturify-0.1.9/tests/test_integration/__init__.py +0 -0
- fixturify-0.1.9/tests/test_integration/fixtures/api_request.json +5 -0
- fixturify-0.1.9/tests/test_integration/fixtures/cleanup.sql +2 -0
- fixturify-0.1.9/tests/test_integration/fixtures/expected_result.json +10 -0
- fixturify-0.1.9/tests/test_integration/fixtures/external_api.json +22 -0
- fixturify-0.1.9/tests/test_integration/fixtures/setup.sql +12 -0
- fixturify-0.1.9/tests/test_integration/test_full_integration.py +215 -0
- fixturify-0.1.9/tests/test_json_assert/__init__.py +1 -0
- fixturify-0.1.9/tests/test_json_assert/fixtures/ACTUAL/nested.json +7 -0
- fixturify-0.1.9/tests/test_json_assert/fixtures/ACTUAL/user.json +4 -0
- fixturify-0.1.9/tests/test_json_assert/fixtures/float_values.json +2 -0
- fixturify-0.1.9/tests/test_json_assert/fixtures/nested.json +11 -0
- fixturify-0.1.9/tests/test_json_assert/fixtures/unordered_list.json +2 -0
- fixturify-0.1.9/tests/test_json_assert/fixtures/user.json +2 -0
- fixturify-0.1.9/tests/test_json_assert/fixtures/users.json +5 -0
- fixturify-0.1.9/tests/test_json_assert/nested/__init__.py +1 -0
- fixturify-0.1.9/tests/test_json_assert/nested/deep/__init__.py +1 -0
- fixturify-0.1.9/tests/test_json_assert/nested/deep/test_grandparent_path.py +136 -0
- fixturify-0.1.9/tests/test_json_assert/nested/test_parent_path.py +87 -0
- fixturify-0.1.9/tests/test_json_assert/test_comparator.py +183 -0
- fixturify-0.1.9/tests/test_json_assert/test_json_assert.py +267 -0
- fixturify-0.1.9/tests/test_json_assert/test_normalizer.py +113 -0
- fixturify-0.1.9/tests/test_object_mapper/__init__.py +1 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_circular.py +140 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_dataclass.py +259 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_dict.py +94 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_plain.py +148 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_pydantic.py +363 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_special_types.py +191 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_sqlalchemy.py +284 -0
- fixturify-0.1.9/tests/test_object_mapper/test_mapper_sqlmodel.py +385 -0
- fixturify-0.1.9/tests/test_object_mapper/test_type_detector.py +114 -0
- fixturify-0.1.9/tests/test_read/__init__.py +1 -0
- fixturify-0.1.9/tests/test_read/fixtures/company.json +8 -0
- fixturify-0.1.9/tests/test_read/fixtures/config.json +6 -0
- fixturify-0.1.9/tests/test_read/fixtures/pydantic_company.json +14 -0
- fixturify-0.1.9/tests/test_read/fixtures/pydantic_user.json +6 -0
- fixturify-0.1.9/tests/test_read/fixtures/pydantic_users.json +5 -0
- fixturify-0.1.9/tests/test_read/fixtures/sqlalchemy_user.json +6 -0
- fixturify-0.1.9/tests/test_read/fixtures/sqlalchemy_users.json +6 -0
- fixturify-0.1.9/tests/test_read/fixtures/sqlmodel_nested_company.json +14 -0
- fixturify-0.1.9/tests/test_read/fixtures/sqlmodel_user_table.json +6 -0
- fixturify-0.1.9/tests/test_read/fixtures/sqlmodel_users_table.json +5 -0
- fixturify-0.1.9/tests/test_read/fixtures/user.json +2 -0
- fixturify-0.1.9/tests/test_read/fixtures/users.json +5 -0
- fixturify-0.1.9/tests/test_read/nested/__init__.py +1 -0
- fixturify-0.1.9/tests/test_read/nested/deep/__init__.py +1 -0
- fixturify-0.1.9/tests/test_read/nested/deep/test_grandparent_path.py +91 -0
- fixturify-0.1.9/tests/test_read/nested/test_parent_path.py +65 -0
- fixturify-0.1.9/tests/test_read/test_decorator.py +175 -0
- fixturify-0.1.9/tests/test_read/test_decorator_models.py +589 -0
- fixturify-0.1.9/tests/test_read/test_fixture_loader.py +155 -0
- fixturify-0.1.9/tests/test_sql/__init__.py +1 -0
- fixturify-0.1.9/tests/test_sql/conftest.py +12 -0
- fixturify-0.1.9/tests/test_sql/fixtures/cleanup.sql +2 -0
- fixturify-0.1.9/tests/test_sql/fixtures/mysql_cleanup.sql +2 -0
- fixturify-0.1.9/tests/test_sql/fixtures/mysql_multistatement_cleanup.sql +4 -0
- fixturify-0.1.9/tests/test_sql/fixtures/mysql_multistatement_setup.sql +23 -0
- fixturify-0.1.9/tests/test_sql/fixtures/mysql_order_tracker_setup.sql +9 -0
- fixturify-0.1.9/tests/test_sql/fixtures/mysql_setup.sql +11 -0
- fixturify-0.1.9/tests/test_sql/fixtures/mysql_utf8_test.sql +13 -0
- fixturify-0.1.9/tests/test_sql/fixtures/nested/deep.sql +2 -0
- fixturify-0.1.9/tests/test_sql/fixtures/order_cleanup.sql +3 -0
- fixturify-0.1.9/tests/test_sql/fixtures/order_step1.sql +3 -0
- fixturify-0.1.9/tests/test_sql/fixtures/order_step2.sql +3 -0
- fixturify-0.1.9/tests/test_sql/fixtures/order_step3.sql +3 -0
- fixturify-0.1.9/tests/test_sql/fixtures/order_step4.sql +3 -0
- fixturify-0.1.9/tests/test_sql/fixtures/order_tracker_setup.sql +9 -0
- fixturify-0.1.9/tests/test_sql/fixtures/postgres_cleanup.sql +2 -0
- fixturify-0.1.9/tests/test_sql/fixtures/postgres_setup.sql +11 -0
- fixturify-0.1.9/tests/test_sql/fixtures/setup.sql +8 -0
- fixturify-0.1.9/tests/test_sql/fixtures/utf8_cleanup.sql +3 -0
- fixturify-0.1.9/tests/test_sql/fixtures/utf8_test.sql +17 -0
- fixturify-0.1.9/tests/test_sql/mysql/__init__.py +2 -0
- fixturify-0.1.9/tests/test_sql/mysql/conftest.py +21 -0
- fixturify-0.1.9/tests/test_sql/mysql/test_integration.py +132 -0
- fixturify-0.1.9/tests/test_sql/mysql_async/__init__.py +2 -0
- fixturify-0.1.9/tests/test_sql/mysql_async/conftest.py +21 -0
- fixturify-0.1.9/tests/test_sql/mysql_async/test_integration.py +113 -0
- fixturify-0.1.9/tests/test_sql/postgres/__init__.py +2 -0
- fixturify-0.1.9/tests/test_sql/postgres/conftest.py +21 -0
- fixturify-0.1.9/tests/test_sql/postgres/test_integration.py +132 -0
- fixturify-0.1.9/tests/test_sql/postgres_async/__init__.py +2 -0
- fixturify-0.1.9/tests/test_sql/postgres_async/conftest.py +21 -0
- fixturify-0.1.9/tests/test_sql/postgres_async/test_integration.py +107 -0
- fixturify-0.1.9/tests/test_sql/submodule/__init__.py +1 -0
- fixturify-0.1.9/tests/test_sql/submodule/deep/__init__.py +1 -0
- fixturify-0.1.9/tests/test_sql/submodule/deep/test_grandparent_path.py +45 -0
- fixturify-0.1.9/tests/test_sql/submodule/test_nested_path.py +25 -0
- fixturify-0.1.9/tests/test_sql/test_config.py +93 -0
- fixturify-0.1.9/tests/test_sql/test_decorator.py +163 -0
- fixturify-0.1.9/tests/test_sql/test_driver_registry.py +63 -0
- fixturify-0.1.9/tests/test_sql/test_executor.py +157 -0
- fixturify-0.1.9/tests/test_sql/test_fixture_discovery.py +357 -0
- fixturify-0.1.9/tests/test_sql/test_path_resolution.py +45 -0
- fixturify-0.1.9/tests/test_sql/test_phase.py +21 -0
- fixturify-0.1.9/tests/test_utils/__init__.py +1 -0
- fixturify-0.1.9/tests/test_utils/test_constants.py +17 -0
- fixturify-0.1.9/tests/test_utils/test_path_resolver.py +196 -0
- fixturify-0.1.9/uv.lock +1820 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v4
|
|
16
|
+
|
|
17
|
+
- name: Build package
|
|
18
|
+
run: uv build
|
|
19
|
+
|
|
20
|
+
- name: Upload dist
|
|
21
|
+
uses: actions/upload-artifact@v4
|
|
22
|
+
with:
|
|
23
|
+
name: dist
|
|
24
|
+
path: dist/
|
|
25
|
+
|
|
26
|
+
publish:
|
|
27
|
+
needs: build
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
environment: pypi
|
|
30
|
+
permissions:
|
|
31
|
+
id-token: write
|
|
32
|
+
steps:
|
|
33
|
+
- name: Download dist
|
|
34
|
+
uses: actions/download-artifact@v4
|
|
35
|
+
with:
|
|
36
|
+
name: dist
|
|
37
|
+
path: dist/
|
|
38
|
+
|
|
39
|
+
- name: Publish to PyPI
|
|
40
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
.claude
|
|
210
|
+
.idea
|
fixturify-0.1.9/PKG-INFO
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fixturify
|
|
3
|
+
Version: 0.1.9
|
|
4
|
+
Summary: A collection of convenient testing utilities for Python
|
|
5
|
+
Project-URL: Homepage, https://github.com/eleven-sea/pytools
|
|
6
|
+
Project-URL: Repository, https://github.com/eleven-sea/pytools
|
|
7
|
+
Project-URL: Issues, https://github.com/eleven-sea/pytools/issues
|
|
8
|
+
Author: eleven-sea
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: fixtures,json,mocking,pytest,sql,testing
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Framework :: Pytest
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Testing
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: deepdiff>=6.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# pytools
|
|
25
|
+
|
|
26
|
+
A collection of Python testing utilities.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install fixturify
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Modules
|
|
35
|
+
|
|
36
|
+
| Module | Description | Docs |
|
|
37
|
+
|--------|-------------|------|
|
|
38
|
+
| [sql](docs/sql.md) | Execute SQL files before/after tests | [docs/sql.md](docs/sql.md) |
|
|
39
|
+
| [read](docs/read.md) | Inject JSON fixtures into test functions | [docs/read.md](docs/read.md) |
|
|
40
|
+
| [http](docs/http.md) | Record and replay HTTP calls | [docs/http.md](docs/http.md) |
|
|
41
|
+
| [JsonAssert](docs/json_assert.md) | Compare objects to JSON files | [docs/json_assert.md](docs/json_assert.md) |
|
|
42
|
+
| [ObjectMapper](docs/object_mapper.md) | Bidirectional object-JSON mapping | [docs/object_mapper.md](docs/object_mapper.md) |
|
|
43
|
+
|
|
44
|
+
## Quick examples
|
|
45
|
+
|
|
46
|
+
### sql
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from fixturify import sql, Phase
|
|
50
|
+
|
|
51
|
+
@sql(path="./setup.sql")
|
|
52
|
+
@sql(path="./cleanup.sql", phase=Phase.AFTER)
|
|
53
|
+
def test_database():
|
|
54
|
+
# SQL executed before and after test
|
|
55
|
+
pass
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### read
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from fixturify import read
|
|
62
|
+
|
|
63
|
+
@read.fixture(path="./fixtures/user.json", fixture_name="user", object_class=User)
|
|
64
|
+
def test_user(user: User):
|
|
65
|
+
assert user.name == "John"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### http
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from fixturify import http
|
|
72
|
+
|
|
73
|
+
@http(path="./fixtures/api.json")
|
|
74
|
+
def test_api():
|
|
75
|
+
# First run: records HTTP calls
|
|
76
|
+
# Next runs: replays from file
|
|
77
|
+
response = requests.get("https://api.example.com/users")
|
|
78
|
+
assert response.status_code == 200
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### JsonAssert
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from fixturify import JsonAssert
|
|
85
|
+
|
|
86
|
+
def test_response():
|
|
87
|
+
data = {"name": "John", "age": 30}
|
|
88
|
+
JsonAssert(data).ignore("age").compare_to_file("./expected.json")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### ObjectMapper
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from fixturify import ObjectMapper
|
|
95
|
+
|
|
96
|
+
# Object to JSON
|
|
97
|
+
user = User(name="John", age=30)
|
|
98
|
+
data = ObjectMapper(user).to_json()
|
|
99
|
+
|
|
100
|
+
# JSON to object
|
|
101
|
+
data = {"name": "John", "age": 30}
|
|
102
|
+
user = ObjectMapper(data).to_object(User)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Public API
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from fixturify import (
|
|
109
|
+
# Decorators
|
|
110
|
+
sql,
|
|
111
|
+
read,
|
|
112
|
+
http,
|
|
113
|
+
# Enums
|
|
114
|
+
Phase,
|
|
115
|
+
# Config
|
|
116
|
+
SqlTestConfig,
|
|
117
|
+
HttpTestConfig,
|
|
118
|
+
# Classes
|
|
119
|
+
JsonAssert,
|
|
120
|
+
ObjectMapper,
|
|
121
|
+
)
|
|
122
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# pytools
|
|
2
|
+
|
|
3
|
+
A collection of Python testing utilities.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install fixturify
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Modules
|
|
12
|
+
|
|
13
|
+
| Module | Description | Docs |
|
|
14
|
+
|--------|-------------|------|
|
|
15
|
+
| [sql](docs/sql.md) | Execute SQL files before/after tests | [docs/sql.md](docs/sql.md) |
|
|
16
|
+
| [read](docs/read.md) | Inject JSON fixtures into test functions | [docs/read.md](docs/read.md) |
|
|
17
|
+
| [http](docs/http.md) | Record and replay HTTP calls | [docs/http.md](docs/http.md) |
|
|
18
|
+
| [JsonAssert](docs/json_assert.md) | Compare objects to JSON files | [docs/json_assert.md](docs/json_assert.md) |
|
|
19
|
+
| [ObjectMapper](docs/object_mapper.md) | Bidirectional object-JSON mapping | [docs/object_mapper.md](docs/object_mapper.md) |
|
|
20
|
+
|
|
21
|
+
## Quick examples
|
|
22
|
+
|
|
23
|
+
### sql
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from fixturify import sql, Phase
|
|
27
|
+
|
|
28
|
+
@sql(path="./setup.sql")
|
|
29
|
+
@sql(path="./cleanup.sql", phase=Phase.AFTER)
|
|
30
|
+
def test_database():
|
|
31
|
+
# SQL executed before and after test
|
|
32
|
+
pass
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### read
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from fixturify import read
|
|
39
|
+
|
|
40
|
+
@read.fixture(path="./fixtures/user.json", fixture_name="user", object_class=User)
|
|
41
|
+
def test_user(user: User):
|
|
42
|
+
assert user.name == "John"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### http
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from fixturify import http
|
|
49
|
+
|
|
50
|
+
@http(path="./fixtures/api.json")
|
|
51
|
+
def test_api():
|
|
52
|
+
# First run: records HTTP calls
|
|
53
|
+
# Next runs: replays from file
|
|
54
|
+
response = requests.get("https://api.example.com/users")
|
|
55
|
+
assert response.status_code == 200
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### JsonAssert
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from fixturify import JsonAssert
|
|
62
|
+
|
|
63
|
+
def test_response():
|
|
64
|
+
data = {"name": "John", "age": 30}
|
|
65
|
+
JsonAssert(data).ignore("age").compare_to_file("./expected.json")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### ObjectMapper
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from fixturify import ObjectMapper
|
|
72
|
+
|
|
73
|
+
# Object to JSON
|
|
74
|
+
user = User(name="John", age=30)
|
|
75
|
+
data = ObjectMapper(user).to_json()
|
|
76
|
+
|
|
77
|
+
# JSON to object
|
|
78
|
+
data = {"name": "John", "age": 30}
|
|
79
|
+
user = ObjectMapper(data).to_object(User)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Public API
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from fixturify import (
|
|
86
|
+
# Decorators
|
|
87
|
+
sql,
|
|
88
|
+
read,
|
|
89
|
+
http,
|
|
90
|
+
# Enums
|
|
91
|
+
Phase,
|
|
92
|
+
# Config
|
|
93
|
+
SqlTestConfig,
|
|
94
|
+
HttpTestConfig,
|
|
95
|
+
# Classes
|
|
96
|
+
JsonAssert,
|
|
97
|
+
ObjectMapper,
|
|
98
|
+
)
|
|
99
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
services:
|
|
2
|
+
localstack:
|
|
3
|
+
image: localstack/localstack:latest
|
|
4
|
+
ports:
|
|
5
|
+
- "4566:4566"
|
|
6
|
+
environment:
|
|
7
|
+
- SERVICES=s3,sts
|
|
8
|
+
- DEBUG=0
|
|
9
|
+
- DOCKER_HOST=unix:///var/run/docker.sock
|
|
10
|
+
volumes:
|
|
11
|
+
- localstack_data:/var/lib/localstack
|
|
12
|
+
- /var/run/docker.sock:/var/run/docker.sock
|
|
13
|
+
|
|
14
|
+
postgres:
|
|
15
|
+
image: postgres:16-alpine
|
|
16
|
+
ports:
|
|
17
|
+
- "5432:5432"
|
|
18
|
+
environment:
|
|
19
|
+
- POSTGRES_USER=postgres
|
|
20
|
+
- POSTGRES_PASSWORD=postgres
|
|
21
|
+
- POSTGRES_DB=pytools
|
|
22
|
+
volumes:
|
|
23
|
+
- postgres_data:/var/lib/postgresql/data
|
|
24
|
+
healthcheck:
|
|
25
|
+
test: ["CMD-SHELL", "pg_isready -U postgres -d pytools"]
|
|
26
|
+
interval: 5s
|
|
27
|
+
timeout: 5s
|
|
28
|
+
retries: 5
|
|
29
|
+
|
|
30
|
+
mysql:
|
|
31
|
+
image: mysql:8.0
|
|
32
|
+
ports:
|
|
33
|
+
- "3306:3306"
|
|
34
|
+
environment:
|
|
35
|
+
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
|
|
36
|
+
- MYSQL_DATABASE=pytools
|
|
37
|
+
volumes:
|
|
38
|
+
- mysql_data:/var/lib/mysql
|
|
39
|
+
healthcheck:
|
|
40
|
+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
|
41
|
+
interval: 5s
|
|
42
|
+
timeout: 5s
|
|
43
|
+
retries: 5
|
|
44
|
+
|
|
45
|
+
volumes:
|
|
46
|
+
localstack_data:
|
|
47
|
+
postgres_data:
|
|
48
|
+
mysql_data:
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# http
|
|
2
|
+
|
|
3
|
+
Decorator for recording and replaying HTTP calls in tests.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from fixturify import http, HttpTestConfig
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic usage
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import requests
|
|
15
|
+
|
|
16
|
+
@http(path="./fixtures/api_calls.json")
|
|
17
|
+
def test_api():
|
|
18
|
+
response = requests.get("https://api.example.com/users")
|
|
19
|
+
assert response.status_code == 200
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**First run**: makes real HTTP calls and saves them to JSON file.
|
|
23
|
+
|
|
24
|
+
**Subsequent runs**: replays saved responses (no network calls).
|
|
25
|
+
|
|
26
|
+
## Supported HTTP libraries
|
|
27
|
+
|
|
28
|
+
- `requests` (sync)
|
|
29
|
+
- `httpx` (sync and async)
|
|
30
|
+
|
|
31
|
+
## Async functions
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import httpx
|
|
35
|
+
|
|
36
|
+
@http(path="./fixtures/api.json")
|
|
37
|
+
async def test_async_api():
|
|
38
|
+
async with httpx.AsyncClient() as client:
|
|
39
|
+
response = await client.get("https://api.example.com/users")
|
|
40
|
+
assert response.status_code == 200
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
### Via pytest fixture (recommended)
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
# conftest.py
|
|
49
|
+
import pytest
|
|
50
|
+
from fixturify import HttpTestConfig
|
|
51
|
+
|
|
52
|
+
@pytest.fixture
|
|
53
|
+
def http_config() -> HttpTestConfig:
|
|
54
|
+
return HttpTestConfig(
|
|
55
|
+
ignore_request_headers=["Authorization"],
|
|
56
|
+
exclude_request_headers=["Authorization", "X-API-Key"],
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Directly in decorator
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
config = HttpTestConfig(
|
|
64
|
+
ignore_request_headers=["Authorization"],
|
|
65
|
+
strict_order=True,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
@http(path="./fixtures/api.json", config=config)
|
|
69
|
+
def test_api():
|
|
70
|
+
pass
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## HttpTestConfig
|
|
74
|
+
|
|
75
|
+
| Field | Type | Default | Description |
|
|
76
|
+
|-------|------|---------|-------------|
|
|
77
|
+
| `ignore_request_headers` | `List[str]` | `[]` | Headers to ignore when matching requests |
|
|
78
|
+
| `ignore_response_headers` | `List[str]` | `[]` | Headers to ignore when comparing responses |
|
|
79
|
+
| `exclude_request_headers` | `List[str]` | `[]` | Headers to remove from recordings |
|
|
80
|
+
| `exclude_response_headers` | `List[str]` | `[]` | Headers to remove from response recordings |
|
|
81
|
+
| `exclude_hosts` | `List[str]` | `[]` | Hosts excluded from recording/playback |
|
|
82
|
+
| `match_request_body` | `bool` | `True` | Whether to match request body |
|
|
83
|
+
| `strict_order` | `bool` | `False` | Whether requests must occur in same order |
|
|
84
|
+
|
|
85
|
+
## Default ignored headers
|
|
86
|
+
|
|
87
|
+
**Request (ignored during matching)**:
|
|
88
|
+
- `user-agent`, `date`, `accept-encoding`, `content-length`, `connection`, `host`
|
|
89
|
+
|
|
90
|
+
**Request (excluded from recordings)**:
|
|
91
|
+
- `user-agent`, `accept-encoding`, `connection`, `host`
|
|
92
|
+
|
|
93
|
+
**Response (excluded from recordings)**:
|
|
94
|
+
- `date`, `server`, `x-request-id`, `x-correlation-id`, `set-cookie`, `transfer-encoding`, `content-length`
|
|
95
|
+
|
|
96
|
+
## Configuration examples
|
|
97
|
+
|
|
98
|
+
### Ignoring Authorization header
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
config = HttpTestConfig(
|
|
102
|
+
ignore_request_headers=["Authorization"], # don't compare during playback
|
|
103
|
+
exclude_request_headers=["Authorization"], # don't save to file
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Enforcing request order
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
config = HttpTestConfig(strict_order=True)
|
|
111
|
+
|
|
112
|
+
@http(path="./fixtures/api.json", config=config)
|
|
113
|
+
def test_ordered():
|
|
114
|
+
requests.get("https://api.example.com/first") # must be first
|
|
115
|
+
requests.get("https://api.example.com/second") # must be second
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Excluding host from mocking
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
config = HttpTestConfig(
|
|
122
|
+
exclude_hosts=["testserver", "localhost:8000"],
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
@http(path="./fixtures/api.json", config=config)
|
|
126
|
+
def test_with_local_server():
|
|
127
|
+
# These calls go to real server:
|
|
128
|
+
requests.get("http://testserver/api/health")
|
|
129
|
+
|
|
130
|
+
# These are recorded/replayed:
|
|
131
|
+
requests.get("https://external-api.com/data")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Ignoring request body
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
config = HttpTestConfig(match_request_body=False)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Exceptions
|
|
141
|
+
|
|
142
|
+
| Exception | When |
|
|
143
|
+
|-----------|------|
|
|
144
|
+
| `NoMatchingRecordingError` | Request doesn't match any recording |
|
|
145
|
+
| `UnusedRecordingsError` | Some recordings were not used |
|
|
146
|
+
| `RequestMismatchError` | Details about request mismatch |
|
|
147
|
+
|
|
148
|
+
## Re-recording
|
|
149
|
+
|
|
150
|
+
Delete the JSON recordings file and run test again:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
rm tests/fixtures/api_calls.json
|
|
154
|
+
pytest tests/test_api.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Recording file format
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"mappings": [
|
|
162
|
+
{
|
|
163
|
+
"request": {
|
|
164
|
+
"method": "GET",
|
|
165
|
+
"url": "https://api.example.com/users",
|
|
166
|
+
"headers": {"Accept": "application/json"},
|
|
167
|
+
"queryParameters": {},
|
|
168
|
+
"body": null
|
|
169
|
+
},
|
|
170
|
+
"response": {
|
|
171
|
+
"statusCode": 200,
|
|
172
|
+
"headers": {"Content-Type": "application/json"},
|
|
173
|
+
"body": [{"id": 1, "name": "John"}]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Path resolution
|
|
181
|
+
|
|
182
|
+
Paths are resolved relative to the test file:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
tests/
|
|
186
|
+
test_api.py <- @http(path="./fixtures/api.json")
|
|
187
|
+
fixtures/
|
|
188
|
+
api.json <- recordings saved here
|
|
189
|
+
```
|