airbyte-source-rki-covid 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airbyte_source_rki_covid-0.1.4.dist-info/METADATA +110 -0
- airbyte_source_rki_covid-0.1.4.dist-info/RECORD +25 -0
- {airbyte_source_rki_covid-0.1.2.dist-info → airbyte_source_rki_covid-0.1.4.dist-info}/WHEEL +1 -2
- airbyte_source_rki_covid-0.1.4.dist-info/entry_points.txt +3 -0
- source_rki_covid/schemas/TODO.md +30 -0
- airbyte_source_rki_covid-0.1.2.dist-info/METADATA +0 -119
- airbyte_source_rki_covid-0.1.2.dist-info/RECORD +0 -53
- airbyte_source_rki_covid-0.1.2.dist-info/entry_points.txt +0 -2
- airbyte_source_rki_covid-0.1.2.dist-info/top_level.txt +0 -3
- integration_tests/__init__.py +0 -3
- integration_tests/abnormal_state.json +0 -44
- integration_tests/acceptance.py +0 -14
- integration_tests/configured_catalog.json +0 -861
- integration_tests/invalid_config.json +0 -3
- integration_tests/sample_config.json +0 -3
- integration_tests/sample_state.json +0 -18
- unit_tests/__init__.py +0 -3
- unit_tests/test_cached_stream_state.py +0 -5
- unit_tests/test_incremental_germanhistorycases.py +0 -56
- unit_tests/test_incremental_germanhistorydeaths.py +0 -66
- unit_tests/test_incremental_germanhistoryfrozenIncidence.py +0 -66
- unit_tests/test_incremental_germanhistoryhospitalization.py +0 -66
- unit_tests/test_incremental_germanhistoryincidence.py +0 -66
- unit_tests/test_incremental_germanhistoryrecovered.py +0 -66
- unit_tests/test_incremental_streams.py +0 -52
- unit_tests/test_source.py +0 -21
- unit_tests/test_stateshistorycases.py +0 -29
- unit_tests/test_stateshistorydeaths.py +0 -29
- unit_tests/test_stateshistoryfrozenincidence.py +0 -29
- unit_tests/test_stateshistoryhospitalization.py +0 -29
- unit_tests/test_stateshistoryincidence.py +0 -29
- unit_tests/test_stateshistoryrecovered.py +0 -29
- unit_tests/test_stream_agegroup.py +0 -18
- unit_tests/test_stream_germany.py +0 -18
- unit_tests/test_stream_germany_states.py +0 -18
- unit_tests/test_streams.py +0 -67
- unit_tests/test_streams_states_agegroup.py +0 -18
@@ -1,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"germany_history_cases": {
|
3
|
-
"date": "2024-01-01T00:00:00.000Z"
|
4
|
-
},
|
5
|
-
"german_history_incidence": {
|
6
|
-
"date": "2024-01-01T00:00:00.000Z"
|
7
|
-
},
|
8
|
-
"german_history_deaths": {
|
9
|
-
"date": "2024-01-01T00:00:00.000Z"
|
10
|
-
},
|
11
|
-
"german_history_recovered": {
|
12
|
-
"date": "2024-01-01T00:00:00.000Z"
|
13
|
-
},
|
14
|
-
"german_history_hospitalization": {
|
15
|
-
"date": "2024-01-01T00:00:00.000Z"
|
16
|
-
},
|
17
|
-
"german_history_frozen_incidence": {}
|
18
|
-
}
|
unit_tests/__init__.py
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime
|
7
|
-
|
8
|
-
import requests
|
9
|
-
from pytest import fixture
|
10
|
-
from source_rki_covid.source import GermanyHistoryCases
|
11
|
-
|
12
|
-
|
13
|
-
@fixture
|
14
|
-
def patch_incremental_german_history_cases(mocker):
|
15
|
-
# Mock abstract methods to enable instantiating abstract class.
|
16
|
-
mocker.patch.object(GermanyHistoryCases, "primary_key", None)
|
17
|
-
|
18
|
-
|
19
|
-
def test_cursor_field(patch_incremental_german_history_cases):
|
20
|
-
config = {"start_date": "2022-04-27"}
|
21
|
-
stream = GermanyHistoryCases(config)
|
22
|
-
expected_cursor_field = "date"
|
23
|
-
assert stream.cursor_field == expected_cursor_field
|
24
|
-
|
25
|
-
|
26
|
-
def test_parse_response(patch_incremental_german_history_cases):
|
27
|
-
config = {"start_date": "2022-04-27"}
|
28
|
-
stream = GermanyHistoryCases(config)
|
29
|
-
response = requests.get("https://api.corona-zahlen.org/germany/history/cases/1")
|
30
|
-
if response.json().get("data"):
|
31
|
-
expected_response = response.json().get("data")
|
32
|
-
assert stream.parse_response(response) == expected_response
|
33
|
-
else:
|
34
|
-
expected_response = [{}]
|
35
|
-
assert stream.parse_response(response) == expected_response
|
36
|
-
|
37
|
-
|
38
|
-
def check_diff(start_date):
|
39
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
40
|
-
if diff.days <= 0:
|
41
|
-
return str(1)
|
42
|
-
return str(diff.days)
|
43
|
-
|
44
|
-
|
45
|
-
def test_parse_with_cases(patch_incremental_german_history_cases):
|
46
|
-
config = {"start_date": "2022-04-27"}
|
47
|
-
stream = GermanyHistoryCases(config)
|
48
|
-
expected_stream_path = "germany/history/cases/" + check_diff(config.get("start_date"))
|
49
|
-
assert stream.path() == expected_stream_path
|
50
|
-
|
51
|
-
|
52
|
-
def test_parse_without_cases(patch_incremental_german_history_cases):
|
53
|
-
config = {}
|
54
|
-
stream = GermanyHistoryCases(config)
|
55
|
-
expected_stream_path = "germany/history/cases/"
|
56
|
-
assert stream.path() == expected_stream_path
|
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime, timedelta
|
7
|
-
|
8
|
-
import requests
|
9
|
-
from pytest import fixture
|
10
|
-
from source_rki_covid.source import GermanHistoryDeaths
|
11
|
-
|
12
|
-
|
13
|
-
@fixture
|
14
|
-
def patch_incremental_german_history_deaths(mocker):
|
15
|
-
# Mock abstract methods to enable instantiating abstract class
|
16
|
-
mocker.patch.object(GermanHistoryDeaths, "primary_key", None)
|
17
|
-
|
18
|
-
|
19
|
-
def test_cursor_field(patch_incremental_german_history_deaths):
|
20
|
-
config = {"start_date": "2022-04-27"}
|
21
|
-
stream = GermanHistoryDeaths(config)
|
22
|
-
expected_cursor_field = "date"
|
23
|
-
assert stream.cursor_field == expected_cursor_field
|
24
|
-
|
25
|
-
|
26
|
-
def test_get_updated_state(patch_incremental_german_history_deaths):
|
27
|
-
config = {"start_date": "2022-04-27"}
|
28
|
-
stream = GermanHistoryDeaths(config)
|
29
|
-
d = datetime.date(datetime.today()) - timedelta(days=1)
|
30
|
-
date = {stream.cursor_field: str(d)}
|
31
|
-
inputs = {"current_stream_state": date, "latest_record": date}
|
32
|
-
expected_state = {stream.cursor_field: str(d)}
|
33
|
-
assert stream.get_updated_state(**inputs) == expected_state
|
34
|
-
|
35
|
-
|
36
|
-
def test_parse_response(patch_incremental_german_history_deaths):
|
37
|
-
config = {"start_date": "2022-04-27"}
|
38
|
-
stream = GermanHistoryDeaths(config)
|
39
|
-
response = requests.get("https://api.corona-zahlen.org/germany/history/deaths/1")
|
40
|
-
if response.json().get("data"):
|
41
|
-
expected_response = response.json().get("data")
|
42
|
-
assert stream.parse_response(response) == expected_response
|
43
|
-
else:
|
44
|
-
expected_response = [{}]
|
45
|
-
assert stream.parse_response(response) == expected_response
|
46
|
-
|
47
|
-
|
48
|
-
def check_diff(start_date):
|
49
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
50
|
-
if diff.days <= 0:
|
51
|
-
return str(1)
|
52
|
-
return str(diff.days)
|
53
|
-
|
54
|
-
|
55
|
-
def test_parse_with_cases(patch_incremental_german_history_deaths):
|
56
|
-
config = {"start_date": "2022-04-27"}
|
57
|
-
stream = GermanHistoryDeaths(config)
|
58
|
-
expected_stream_path = "germany/history/deaths/" + check_diff(config.get("start_date"))
|
59
|
-
assert stream.path() == expected_stream_path
|
60
|
-
|
61
|
-
|
62
|
-
def test_parse_without_cases(patch_incremental_german_history_deaths):
|
63
|
-
config = {}
|
64
|
-
stream = GermanHistoryDeaths(config)
|
65
|
-
expected_stream_path = "germany/history/deaths/"
|
66
|
-
assert stream.path() == expected_stream_path
|
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime, timedelta
|
7
|
-
|
8
|
-
import requests
|
9
|
-
from pytest import fixture
|
10
|
-
from source_rki_covid.source import GermanHistoryFrozenIncidence
|
11
|
-
|
12
|
-
|
13
|
-
@fixture
|
14
|
-
def patch_incremental_german_history_frozenInc(mocker):
|
15
|
-
# Mock abstract methods to enable instantiating abstract class
|
16
|
-
mocker.patch.object(GermanHistoryFrozenIncidence, "primary_key", None)
|
17
|
-
|
18
|
-
|
19
|
-
def test_cursor_field(patch_incremental_german_history_frozenInc):
|
20
|
-
config = {"start_date": "2022-04-27"}
|
21
|
-
stream = GermanHistoryFrozenIncidence(config)
|
22
|
-
expected_cursor_field = "date"
|
23
|
-
assert stream.cursor_field == expected_cursor_field
|
24
|
-
|
25
|
-
|
26
|
-
def test_get_updated_state(patch_incremental_german_history_frozenInc):
|
27
|
-
config = {"start_date": "2022-04-27"}
|
28
|
-
stream = GermanHistoryFrozenIncidence(config)
|
29
|
-
d = datetime.date(datetime.today()) - timedelta(days=1)
|
30
|
-
date = {stream.cursor_field: str(d)}
|
31
|
-
inputs = {"current_stream_state": date, "latest_record": date}
|
32
|
-
expected_state = {stream.cursor_field: str(d)}
|
33
|
-
assert stream.get_updated_state(**inputs) == expected_state
|
34
|
-
|
35
|
-
|
36
|
-
def test_parse_response(patch_incremental_german_history_frozenInc):
|
37
|
-
config = {"start_date": "2022-04-27"}
|
38
|
-
stream = GermanHistoryFrozenIncidence(config)
|
39
|
-
response = requests.get("https://api.corona-zahlen.org/germany/history/frozen-incidence/1")
|
40
|
-
if response.json().get("data").get("history"):
|
41
|
-
expected_response = response.json().get("data").get("history")
|
42
|
-
assert stream.parse_response(response) == expected_response
|
43
|
-
else:
|
44
|
-
expected_response = []
|
45
|
-
assert stream.parse_response(response) == expected_response
|
46
|
-
|
47
|
-
|
48
|
-
def check_diff(start_date):
|
49
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
50
|
-
if diff.days <= 0:
|
51
|
-
return str(1)
|
52
|
-
return str(diff.days)
|
53
|
-
|
54
|
-
|
55
|
-
def test_parse_with_cases(patch_incremental_german_history_frozenInc):
|
56
|
-
config = {"start_date": "2022-04-27"}
|
57
|
-
stream = GermanHistoryFrozenIncidence(config)
|
58
|
-
expected_stream_path = "germany/history/frozen-incidence/" + check_diff(config.get("start_date"))
|
59
|
-
assert stream.path() == expected_stream_path
|
60
|
-
|
61
|
-
|
62
|
-
def test_parse_without_cases(patch_incremental_german_history_frozenInc):
|
63
|
-
config = {}
|
64
|
-
stream = GermanHistoryFrozenIncidence(config)
|
65
|
-
expected_stream_path = "germany/history/frozen-incidence/"
|
66
|
-
assert stream.path() == expected_stream_path
|
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime, timedelta
|
7
|
-
|
8
|
-
import requests
|
9
|
-
from pytest import fixture
|
10
|
-
from source_rki_covid.source import GermanHistoryHospitalization
|
11
|
-
|
12
|
-
|
13
|
-
@fixture
|
14
|
-
def patch_incremental_german_history_hospitalization(mocker):
|
15
|
-
# Mock abstract methods to enable instantiating abstract class
|
16
|
-
mocker.patch.object(GermanHistoryHospitalization, "primary_key", None)
|
17
|
-
|
18
|
-
|
19
|
-
def test_cursor_field(patch_incremental_german_history_hospitalization):
|
20
|
-
config = {"start_date": "2022-04-27"}
|
21
|
-
stream = GermanHistoryHospitalization(config)
|
22
|
-
expected_cursor_field = "date"
|
23
|
-
assert stream.cursor_field == expected_cursor_field
|
24
|
-
|
25
|
-
|
26
|
-
def test_get_updated_state(patch_incremental_german_history_hospitalization):
|
27
|
-
config = {"start_date": "2022-04-27"}
|
28
|
-
stream = GermanHistoryHospitalization(config)
|
29
|
-
d = datetime.date(datetime.today()) - timedelta(days=1)
|
30
|
-
date = {stream.cursor_field: str(d)}
|
31
|
-
inputs = {"current_stream_state": date, "latest_record": date}
|
32
|
-
expected_state = {stream.cursor_field: str(d)}
|
33
|
-
assert stream.get_updated_state(**inputs) == expected_state
|
34
|
-
|
35
|
-
|
36
|
-
def test_parse_response(patch_incremental_german_history_hospitalization):
|
37
|
-
config = {"start_date": "2022-04-27"}
|
38
|
-
stream = GermanHistoryHospitalization(config)
|
39
|
-
response = requests.get("https://api.corona-zahlen.org/germany/history/hospitalization/1")
|
40
|
-
if response.json().get("data"):
|
41
|
-
expected_response = response.json().get("data")
|
42
|
-
assert stream.parse_response(response) == expected_response
|
43
|
-
else:
|
44
|
-
expected_response = [{}]
|
45
|
-
assert stream.parse_response(response) == expected_response
|
46
|
-
|
47
|
-
|
48
|
-
def check_diff(start_date):
|
49
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
50
|
-
if diff.days <= 0:
|
51
|
-
return str(1)
|
52
|
-
return str(diff.days)
|
53
|
-
|
54
|
-
|
55
|
-
def test_parse_with_cases(patch_incremental_german_history_hospitalization):
|
56
|
-
config = {"start_date": "2022-04-27"}
|
57
|
-
stream = GermanHistoryHospitalization(config)
|
58
|
-
expected_stream_path = "germany/history/hospitalization/" + check_diff(config.get("start_date"))
|
59
|
-
assert stream.path() == expected_stream_path
|
60
|
-
|
61
|
-
|
62
|
-
def test_parse_without_cases(patch_incremental_german_history_hospitalization):
|
63
|
-
config = {}
|
64
|
-
stream = GermanHistoryHospitalization(config)
|
65
|
-
expected_stream_path = "germany/history/hospitalization/"
|
66
|
-
assert stream.path() == expected_stream_path
|
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime, timedelta
|
7
|
-
|
8
|
-
import requests
|
9
|
-
from pytest import fixture
|
10
|
-
from source_rki_covid.source import GermanHistoryIncidence
|
11
|
-
|
12
|
-
|
13
|
-
@fixture
|
14
|
-
def patch_incremental_german_history_incidence(mocker):
|
15
|
-
# Mock abstract methods to enable instantiating abstract class
|
16
|
-
mocker.patch.object(GermanHistoryIncidence, "primary_key", None)
|
17
|
-
|
18
|
-
|
19
|
-
def test_cursor_field(patch_incremental_german_history_incidence):
|
20
|
-
config = {"start_date": "2022-04-27"}
|
21
|
-
stream = GermanHistoryIncidence(config)
|
22
|
-
expected_cursor_field = "date"
|
23
|
-
assert stream.cursor_field == expected_cursor_field
|
24
|
-
|
25
|
-
|
26
|
-
def test_get_updated_state(patch_incremental_german_history_incidence):
|
27
|
-
config = {"start_date": "2022-04-27"}
|
28
|
-
stream = GermanHistoryIncidence(config)
|
29
|
-
d = datetime.date(datetime.today()) - timedelta(days=1)
|
30
|
-
date = {stream.cursor_field: str(d)}
|
31
|
-
inputs = {"current_stream_state": date, "latest_record": date}
|
32
|
-
expected_state = {stream.cursor_field: str(d)}
|
33
|
-
assert stream.get_updated_state(**inputs) == expected_state
|
34
|
-
|
35
|
-
|
36
|
-
def test_parse_response(patch_incremental_german_history_incidence):
|
37
|
-
config = {"start_date": "2022-04-27"}
|
38
|
-
stream = GermanHistoryIncidence(config)
|
39
|
-
response = requests.get("https://api.corona-zahlen.org/germany/history/incidence/1")
|
40
|
-
if response.json().get("data"):
|
41
|
-
expected_response = response.json().get("data")
|
42
|
-
assert stream.parse_response(response) == expected_response
|
43
|
-
else:
|
44
|
-
expected_response = [{}]
|
45
|
-
assert stream.parse_response(response) == expected_response
|
46
|
-
|
47
|
-
|
48
|
-
def check_diff(start_date):
|
49
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
50
|
-
if diff.days <= 0:
|
51
|
-
return str(1)
|
52
|
-
return str(diff.days)
|
53
|
-
|
54
|
-
|
55
|
-
def test_parse_with_cases(patch_incremental_german_history_incidence):
|
56
|
-
config = {"start_date": "2022-04-27"}
|
57
|
-
stream = GermanHistoryIncidence(config)
|
58
|
-
expected_stream_path = "germany/history/incidence/" + check_diff(config.get("start_date"))
|
59
|
-
assert stream.path() == expected_stream_path
|
60
|
-
|
61
|
-
|
62
|
-
def test_parse_without_cases(patch_incremental_german_history_incidence):
|
63
|
-
config = {}
|
64
|
-
stream = GermanHistoryIncidence(config)
|
65
|
-
expected_stream_path = "germany/history/incidence/"
|
66
|
-
assert stream.path() == expected_stream_path
|
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime, timedelta
|
7
|
-
|
8
|
-
import requests
|
9
|
-
from pytest import fixture
|
10
|
-
from source_rki_covid.source import GermanHistoryRecovered
|
11
|
-
|
12
|
-
|
13
|
-
@fixture
|
14
|
-
def patch_incremental_german_history_recovered(mocker):
|
15
|
-
# Mock abstract methods to enable instantiating abstract class
|
16
|
-
mocker.patch.object(GermanHistoryRecovered, "primary_key", None)
|
17
|
-
|
18
|
-
|
19
|
-
def test_cursor_field(patch_incremental_german_history_recovered):
|
20
|
-
config = {"start_date": "2022-04-27"}
|
21
|
-
stream = GermanHistoryRecovered(config)
|
22
|
-
expected_cursor_field = "date"
|
23
|
-
assert stream.cursor_field == expected_cursor_field
|
24
|
-
|
25
|
-
|
26
|
-
def test_get_updated_state(patch_incremental_german_history_recovered):
|
27
|
-
config = {"start_date": "2022-04-27"}
|
28
|
-
stream = GermanHistoryRecovered(config)
|
29
|
-
d = datetime.date(datetime.today()) - timedelta(days=1)
|
30
|
-
date = {stream.cursor_field: str(d)}
|
31
|
-
inputs = {"current_stream_state": date, "latest_record": date}
|
32
|
-
expected_state = {stream.cursor_field: str(d)}
|
33
|
-
assert stream.get_updated_state(**inputs) == expected_state
|
34
|
-
|
35
|
-
|
36
|
-
def test_parse_response(patch_incremental_german_history_recovered):
|
37
|
-
config = {"start_date": "2022-04-27"}
|
38
|
-
stream = GermanHistoryRecovered(config)
|
39
|
-
response = requests.get("https://api.corona-zahlen.org/germany/history/recovered/1")
|
40
|
-
if response.json().get("data"):
|
41
|
-
expected_response = response.json().get("data")
|
42
|
-
assert stream.parse_response(response) == expected_response
|
43
|
-
else:
|
44
|
-
expected_response = [{}]
|
45
|
-
assert stream.parse_response(response) == expected_response
|
46
|
-
|
47
|
-
|
48
|
-
def check_diff(start_date):
|
49
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
50
|
-
if diff.days <= 0:
|
51
|
-
return str(1)
|
52
|
-
return str(diff.days)
|
53
|
-
|
54
|
-
|
55
|
-
def test_parse_with_cases(patch_incremental_german_history_recovered):
|
56
|
-
config = {"start_date": "2022-04-27"}
|
57
|
-
stream = GermanHistoryRecovered(config)
|
58
|
-
expected_stream_path = "germany/history/recovered/" + check_diff(config.get("start_date"))
|
59
|
-
assert stream.path() == expected_stream_path
|
60
|
-
|
61
|
-
|
62
|
-
def test_parse_without_cases(patch_incremental_german_history_recovered):
|
63
|
-
config = {}
|
64
|
-
stream = GermanHistoryRecovered(config)
|
65
|
-
expected_stream_path = "germany/history/recovered/"
|
66
|
-
assert stream.path() == expected_stream_path
|
@@ -1,52 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from airbyte_cdk.models import SyncMode
|
7
|
-
from pytest import fixture
|
8
|
-
from source_rki_covid.source import IncrementalRkiCovidStream
|
9
|
-
|
10
|
-
|
11
|
-
@fixture
|
12
|
-
def patch_incremental_base_class(mocker):
|
13
|
-
mocker.patch.object(IncrementalRkiCovidStream, "path", "v0/example_endpoint")
|
14
|
-
mocker.patch.object(IncrementalRkiCovidStream, "primary_key", "test_primary_key")
|
15
|
-
mocker.patch.object(IncrementalRkiCovidStream, "__abstractmethods__", set())
|
16
|
-
|
17
|
-
|
18
|
-
def test_cursor_field(patch_incremental_base_class):
|
19
|
-
stream = IncrementalRkiCovidStream()
|
20
|
-
expected_cursor_field = []
|
21
|
-
assert stream.cursor_field == expected_cursor_field
|
22
|
-
|
23
|
-
|
24
|
-
def test_get_updated_state(patch_incremental_base_class):
|
25
|
-
stream = IncrementalRkiCovidStream()
|
26
|
-
inputs = {"current_stream_state": None, "latest_record": None}
|
27
|
-
expected_state = {}
|
28
|
-
assert stream.get_updated_state(**inputs) == expected_state
|
29
|
-
|
30
|
-
|
31
|
-
def test_stream_slices(patch_incremental_base_class):
|
32
|
-
stream = IncrementalRkiCovidStream()
|
33
|
-
inputs = {"sync_mode": SyncMode.incremental, "cursor_field": [], "stream_state": {}}
|
34
|
-
expected_stream_slice = [None]
|
35
|
-
assert stream.stream_slices(**inputs) == expected_stream_slice
|
36
|
-
|
37
|
-
|
38
|
-
def test_supports_incremental(patch_incremental_base_class, mocker):
|
39
|
-
mocker.patch.object(IncrementalRkiCovidStream, "cursor_field", "dummy_field")
|
40
|
-
stream = IncrementalRkiCovidStream()
|
41
|
-
assert stream.supports_incremental
|
42
|
-
|
43
|
-
|
44
|
-
def test_source_defined_cursor(patch_incremental_base_class):
|
45
|
-
stream = IncrementalRkiCovidStream()
|
46
|
-
assert stream.source_defined_cursor
|
47
|
-
|
48
|
-
|
49
|
-
def test_stream_checkpoint_interval(patch_incremental_base_class):
|
50
|
-
stream = IncrementalRkiCovidStream()
|
51
|
-
expected_checkpoint_interval = None
|
52
|
-
assert stream.state_checkpoint_interval == expected_checkpoint_interval
|
unit_tests/test_source.py
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
from unittest.mock import MagicMock
|
6
|
-
|
7
|
-
from source_rki_covid.source import SourceRkiCovid
|
8
|
-
|
9
|
-
|
10
|
-
def test_check_connection(mocker):
|
11
|
-
source = SourceRkiCovid()
|
12
|
-
logger_mock, config_mock = MagicMock(), MagicMock()
|
13
|
-
assert source.check_connection(logger_mock, config_mock) == (True, None)
|
14
|
-
|
15
|
-
|
16
|
-
def test_streams(mocker):
|
17
|
-
source = SourceRkiCovid()
|
18
|
-
config_mock = MagicMock()
|
19
|
-
streams = source.streams(config_mock)
|
20
|
-
expected_streams_number = 16
|
21
|
-
assert len(streams) == expected_streams_number
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime
|
7
|
-
|
8
|
-
from pytest import fixture
|
9
|
-
from source_rki_covid.source import StatesHistoryCases
|
10
|
-
|
11
|
-
|
12
|
-
@fixture
|
13
|
-
def patch_states_history_cases(mocker):
|
14
|
-
# Mock abstract methods to enable instantiating abstract class
|
15
|
-
mocker.patch.object(StatesHistoryCases, "primary_key", None)
|
16
|
-
|
17
|
-
|
18
|
-
def check_diff(start_date):
|
19
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
20
|
-
if diff.days <= 0:
|
21
|
-
return str(1)
|
22
|
-
return str(diff.days)
|
23
|
-
|
24
|
-
|
25
|
-
def test_parse_with_cases(patch_states_history_cases):
|
26
|
-
config = {"start_date": "2022-04-27"}
|
27
|
-
stream = StatesHistoryCases(config)
|
28
|
-
expected_stream_path = "states/history/cases/" + check_diff(config.get("start_date"))
|
29
|
-
assert stream.path() == expected_stream_path
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime
|
7
|
-
|
8
|
-
from pytest import fixture
|
9
|
-
from source_rki_covid.source import StatesHistoryDeaths
|
10
|
-
|
11
|
-
|
12
|
-
@fixture
|
13
|
-
def patch_states_history_deaths(mocker):
|
14
|
-
# Mock abstract methods to enable instantiating abstract class
|
15
|
-
mocker.patch.object(StatesHistoryDeaths, "primary_key", None)
|
16
|
-
|
17
|
-
|
18
|
-
def check_diff(start_date):
|
19
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
20
|
-
if diff.days <= 0:
|
21
|
-
return str(1)
|
22
|
-
return str(diff.days)
|
23
|
-
|
24
|
-
|
25
|
-
def test_parse_with_cases(patch_states_history_deaths):
|
26
|
-
config = {"start_date": "2022-04-27"}
|
27
|
-
stream = StatesHistoryDeaths(config)
|
28
|
-
expected_stream_path = "states/history/deaths/" + check_diff(config.get("start_date"))
|
29
|
-
assert stream.path() == expected_stream_path
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime
|
7
|
-
|
8
|
-
from pytest import fixture
|
9
|
-
from source_rki_covid.source import StatesHistoryFrozenIncidence
|
10
|
-
|
11
|
-
|
12
|
-
@fixture
|
13
|
-
def patch_states_history_frozenincidence(mocker):
|
14
|
-
# Mock abstract methods to enable instantiating abstract class
|
15
|
-
mocker.patch.object(StatesHistoryFrozenIncidence, "primary_key", None)
|
16
|
-
|
17
|
-
|
18
|
-
def check_diff(start_date):
|
19
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
20
|
-
if diff.days <= 0:
|
21
|
-
return str(1)
|
22
|
-
return str(diff.days)
|
23
|
-
|
24
|
-
|
25
|
-
def test_parse_with_cases(patch_states_history_frozenincidence):
|
26
|
-
config = {"start_date": "2022-04-27"}
|
27
|
-
stream = StatesHistoryFrozenIncidence(config)
|
28
|
-
expected_stream_path = "states/history/frozen-incidence/" + check_diff(config.get("start_date"))
|
29
|
-
assert stream.path() == expected_stream_path
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime
|
7
|
-
|
8
|
-
from pytest import fixture
|
9
|
-
from source_rki_covid.source import StatesHistoryHospitalization
|
10
|
-
|
11
|
-
|
12
|
-
@fixture
|
13
|
-
def patch_states_history_hospitalization(mocker):
|
14
|
-
# Mock abstract methods to enable instantiating abstract class
|
15
|
-
mocker.patch.object(StatesHistoryHospitalization, "primary_key", None)
|
16
|
-
|
17
|
-
|
18
|
-
def check_diff(start_date):
|
19
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
20
|
-
if diff.days <= 0:
|
21
|
-
return str(1)
|
22
|
-
return str(diff.days)
|
23
|
-
|
24
|
-
|
25
|
-
def test_parse_with_cases(patch_states_history_hospitalization):
|
26
|
-
config = {"start_date": "2022-04-27"}
|
27
|
-
stream = StatesHistoryHospitalization(config)
|
28
|
-
expected_stream_path = "states/history/hospitalization/" + check_diff(config.get("start_date"))
|
29
|
-
assert stream.path() == expected_stream_path
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
from datetime import datetime
|
7
|
-
|
8
|
-
from pytest import fixture
|
9
|
-
from source_rki_covid.source import StatesHistoryIncidence
|
10
|
-
|
11
|
-
|
12
|
-
@fixture
|
13
|
-
def patch_states_history_incidence(mocker):
|
14
|
-
# Mock abstract methods to enable instantiating abstract class
|
15
|
-
mocker.patch.object(StatesHistoryIncidence, "primary_key", None)
|
16
|
-
|
17
|
-
|
18
|
-
def check_diff(start_date):
|
19
|
-
diff = datetime.now() - datetime.strptime(start_date, "%Y-%m-%d")
|
20
|
-
if diff.days <= 0:
|
21
|
-
return str(1)
|
22
|
-
return str(diff.days)
|
23
|
-
|
24
|
-
|
25
|
-
def test_parse_with_cases(patch_states_history_incidence):
|
26
|
-
config = {"start_date": "2022-04-27"}
|
27
|
-
stream = StatesHistoryIncidence(config)
|
28
|
-
expected_stream_path = "states/history/incidence/" + check_diff(config.get("start_date"))
|
29
|
-
assert stream.path() == expected_stream_path
|