-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[source-us-census] fix empty fields after sync #45331
Merged
+595
−215
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d955820
fix schema
topefolorunso e735f7f
Merge branch 'master' of https://github.com/airbytehq/airbyte into to…
topefolorunso 8b76a4a
Update us-census.md
topefolorunso d235722
chore: auto-fix lint and format issues
octavia-squidington-iii 9b4b0c9
add unit test
topefolorunso 31b2e4c
Merge branch 'master' into tope/us-census/fix-empty-fields
topefolorunso 82d5645
chore: auto-fix lint and format issues
octavia-squidington-iii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@topefolorunso can you add some unit tests to verify this works as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests added now @girarda