-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[source-us-census] fix empty fields after sync (#45331)
Co-authored-by: Octavia Squidington III <[email protected]>
- Loading branch information
1 parent
7056428
commit 19335d6
Showing
7 changed files
with
595 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
649 changes: 453 additions & 196 deletions
649
airbyte-integrations/connectors/source-us-census/poetry.lock
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",] | |
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.poetry] | ||
version = "0.2.0" | ||
version = "0.2.1" | ||
name = "source-us-census" | ||
description = "Source implementation for Us Census." | ||
authors = [ "Airbyte <[email protected]>",] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
airbyte-integrations/connectors/source-us-census/unit_tests/test_components.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
|
||
from dataclasses import dataclass | ||
from typing import Any, Mapping | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
from source_us_census.components import USCensusSchema | ||
|
||
|
||
@dataclass | ||
class MockConfig: | ||
query_params: str = None | ||
|
||
def get(self, key): | ||
if key == "query_params": | ||
return self.query_params | ||
|
||
|
||
@pytest.fixture | ||
def census_schema(): | ||
def _create_schema(query_params=None): | ||
config = MockConfig(query_params=query_params) | ||
return USCensusSchema(config=config) | ||
return _create_schema | ||
|
||
|
||
def test_get_json_schema_basic_case(census_schema): | ||
schema_instance = census_schema(query_params="get=NAME,POP&for=state:*") | ||
schema = schema_instance.get_json_schema() | ||
|
||
expected_properties = { | ||
"NAME": {"type": "string"}, | ||
"POP": {"type": "string"}, | ||
"state": {"type": "string"} | ||
} | ||
|
||
assert schema["properties"] == expected_properties | ||
assert schema["$schema"] == "http://json-schema.org/draft-07/schema#" | ||
assert schema["type"] == "object" | ||
assert schema["additionalProperties"] is True | ||
|
||
|
||
def test_get_json_schema_with_get_param(census_schema): | ||
schema_instance = census_schema(query_params="get=NAME,AGE,EMPLOYMENT") | ||
schema = schema_instance.get_json_schema() | ||
|
||
expected_properties = { | ||
"NAME": {"type": "string"}, | ||
"AGE": {"type": "string"}, | ||
"EMPLOYMENT": {"type": "string"} | ||
} | ||
|
||
assert schema["properties"] == expected_properties | ||
|
||
|
||
def test_get_json_schema_with_for_param(census_schema): | ||
schema_instance = census_schema(query_params="for=county:1234") | ||
schema = schema_instance.get_json_schema() | ||
|
||
expected_properties = { | ||
"county": {"type": "string"} | ||
} | ||
|
||
assert schema["properties"] == expected_properties | ||
|
||
|
||
def test_get_json_schema_with_additional_params(census_schema): | ||
schema_instance = census_schema(query_params="get=NAME&year=2020&for=us:*") | ||
schema = schema_instance.get_json_schema() | ||
|
||
expected_properties = { | ||
"NAME": {"type": "string"}, | ||
"year": {"type": "string"}, | ||
"us": {"type": "string"} | ||
} | ||
|
||
assert schema["properties"] == expected_properties | ||
|
||
|
||
def test_get_json_schema_no_query_params(census_schema): | ||
schema_instance = census_schema(query_params=None) | ||
schema = schema_instance.get_json_schema() | ||
|
||
expected_properties = { | ||
"{ @context: https://project-open-data.cio.gov/v1.1/schema/catalog.jsonld": {"type": "string"} | ||
} | ||
|
||
assert schema["properties"] == expected_properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters