1
0
mirror of synced 2025-12-25 02:09:19 -05:00

🎉 New Source: Firebase Realtime Database (#18029)

* implement check for source-firebase-realtime-database

* implement discover

* support only one stream

* implement read and tests

* add docs

* remove unnecessary file

* add pr number

* fix sat

* add bootstrap.md

* add badge in builds.md

* fix acceptance.py

* add supported_sync_modes in configured_catalog

* add database_name description and example

* add info about required role for service account

* remove abnormal_state.json

* fill catalog.json with values for testing

* loosen requirements

* Update Dockerfile

* auto-bump connector version

* readd firebase to seed file

* fix build gradle for firebase

---------

Co-authored-by: Tuan Nguyen <anhtuan.nguyen@me.com>
Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
Co-authored-by: marcosmarxm <marcosmarxm@gmail.com>
This commit is contained in:
Koji Matsumoto
2023-03-20 23:42:02 +09:00
committed by GitHub
parent e5f96a3678
commit 73eb77f2a5
28 changed files with 918 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
import string
import pytest
from source_firebase_realtime_database.firebase_rtdb import Records
from source_firebase_realtime_database.source import SourceFirebaseRealtimeDatabase
@pytest.mark.parametrize(
"config, stream_name",
[
(
{"database_name": "my-database", "path": "users"},
"users",
),
(
{"database_name": "my-database", "path": "/users"},
"users",
),
(
{"database_name": "my-database", "path": "path/to/product-details"},
"product_details",
),
(
{"database_name": "my-database", "path": "path/to/product-details/"},
"product_details",
),
(
{"database_name": "my-database", "path": ""},
"my_database",
),
],
)
def test_stream_name_from(config, stream_name):
actual = SourceFirebaseRealtimeDatabase.stream_name_from(config)
expected = stream_name
assert actual == expected
class PseudoClient:
"""
Pseudo client producing records which keys and values are ordered ASCII chcaracter
ex. {"a": "a", "b": "b", "c": "c"}
"""
def __init__(self, buffer_size):
self._buffer_size = buffer_size
def fetch_records(self, start_key=None):
if start_key:
start = ord(start_key) - ord("a")
else:
start = 0
end = start + self._buffer_size
return {c: c for c in string.ascii_lowercase[start:end]}
def test_records():
buffer_size = 5
client = PseudoClient(buffer_size)
records = Records(client)
expected = [{"key": c, "value": f'"{c}"'} for c in string.ascii_lowercase]
actual = list(records)
assert actual == expected