Skip to content

Commit

Permalink
SAT: Validate config according to specification (#4565)
Browse files Browse the repository at this point in the history
* Add config checking according to specification

Co-authored-by: ykurochkin <y.kurochkin@zazmic.com>
  • Loading branch information
yevhenii-ldv and ykurochkin committed Jul 7, 2021
1 parent e2074a4 commit 3dca4ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.1.11
Fix error in the naming of method `test_match_expected` for class `TestSpec`.

## 0.1.10
Add validation of input config.json against spec.json.

## 0.1.9
Add configurable validation of schema for all records in BasicRead test: https://github.com/airbytehq/airbyte/pull/4345
The validation is ON by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY setup.py ./
COPY pytest.ini ./
RUN pip install .

LABEL io.airbyte.version=0.1.9
LABEL io.airbyte.version=0.1.11
LABEL io.airbyte.name=airbyte/source-acceptance-test

ENTRYPOINT ["python", "-m", "pytest", "-p", "source_acceptance_test.plugin"]
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Config:

class SpecTestConfig(BaseConfig):
spec_path: str = spec_path
config_path: str = config_path
timeout_seconds: int = timeout_seconds


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,27 @@
import pytest
from airbyte_cdk.models import AirbyteMessage, ConnectorSpecification, Status, Type
from docker.errors import ContainerError
from jsonschema import validate
from source_acceptance_test.base import BaseTest
from source_acceptance_test.config import BasicReadTestConfig, ConnectionTestConfig
from source_acceptance_test.utils import ConnectorRunner, serialize, verify_records_schema
from source_acceptance_test.utils import ConnectorRunner, SecretDict, serialize, verify_records_schema


@pytest.mark.default_timeout(10)
class TestSpec(BaseTest):
def test_match_expected(self, connector_spec: ConnectorSpecification, docker_runner: ConnectorRunner):
def test_match_expected(self, connector_spec: ConnectorSpecification, connector_config: SecretDict, docker_runner: ConnectorRunner):
output = docker_runner.call_spec()
spec_messages = [message for message in output if message.type == Type.SPEC]

assert len(spec_messages) == 1, "Spec message should be emitted exactly once"
if connector_spec:
assert spec_messages[0].spec == connector_spec, "Spec should be equal to the one in spec.json file"

# Getting rid of technical variables that start with an underscore
config = {key: value for key, value in connector_config.data.items() if not key.startswith("_")}

validate(instance=config, schema=spec_messages[0].spec.connectionSpecification)

def test_required(self):
"""Check that connector will fail if any required field is missing"""

Expand Down

0 comments on commit 3dca4ee

Please sign in to comment.