* 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>
74 lines
1.8 KiB
Python
74 lines
1.8 KiB
Python
#
|
|
# 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
|