1
0
mirror of synced 2026-01-02 21:02:43 -05:00
Files
airbyte/airbyte-cdk/python/unit_tests/sources/file_based/conftest.py
Catherine Noll f464a330f8 File-based CDK module scaffolding (#27122)
Includes CSV schema inference & record parser (#27176)

---------

Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
Co-authored-by: Alexandre Girard <alexandre@airbyte.io>
2023-06-19 11:01:11 -04:00

36 lines
978 B
Python

#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
import json
import os
import sys
import pytest
CONNECTION_SPECIFICATION = {
"type": "object",
"additionalProperties": True,
}
@pytest.fixture
def json_spec():
# Our way of resolving the absolute path to root of the airbyte-cdk unit test directory where spec.yaml files should
# be written to (i.e. ~/airbyte/airbyte-cdk/python/unit-tests) because that is where they are read from during testing.
module = sys.modules[__name__]
module_path = os.path.abspath(module.__file__)
test_path = os.path.dirname(module_path)
spec_root = test_path.split("/sources/file_based")[0]
spec = {
"documentationUrl": "https://airbyte.com/#yaml-from-external",
"connectionSpecification": CONNECTION_SPECIFICATION,
}
json_path = os.path.join(spec_root, "spec.json")
with open(json_path, "w") as f:
f.write(json.dumps(spec))
yield
os.remove(json_path)