MCPcopy
hub / github.com/dlt-hub/dlt / test_dependent_resource

Function test_dependent_resource

tests/load/sources/rest_api/test_rest_api_source.py:66–126  ·  view source on GitHub ↗
(destination_config: DestinationTestConfiguration)

Source from the content-addressed store, hash-verified

64 ids=lambda x: x.name,
65)
66def test_dependent_resource(destination_config: DestinationTestConfiguration) -> None:
67 config: RESTAPIConfig = {
68 "client": {
69 "base_url": "https://pokeapi.apps.dlthub.com/api/v2/",
70 },
71 "resource_defaults": {
72 "endpoint": {
73 "params": {
74 "limit": 1000,
75 },
76 }
77 },
78 "resources": [
79 {
80 "name": "pokemon_list",
81 "endpoint": {
82 "path": "pokemon",
83 "paginator": SinglePagePaginator(),
84 "data_selector": "results",
85 "params": {
86 "limit": 2,
87 },
88 },
89 "selected": False,
90 },
91 {
92 "name": "pokemon",
93 "endpoint": {
94 "path": "pokemon/{name}",
95 "params": {
96 "name": {
97 "type": "resolve",
98 "resource": "pokemon_list",
99 "field": "name",
100 },
101 },
102 },
103 },
104 ],
105 }
106
107 data = rest_api_source(config)
108 pipeline = destination_config.setup_pipeline("test_dependent_resource", dev_mode=True)
109 load_info = pipeline.run(data)
110 assert_load_info(load_info)
111 table_counts = load_table_counts(pipeline)
112
113 assert set(table_counts.keys()) == {
114 "pokemon",
115 "pokemon__types",
116 "pokemon__stats",
117 "pokemon__moves__version_group_details",
118 "pokemon__past_abilities",
119 "pokemon__past_abilities__abilities",
120 "pokemon__moves",
121 "pokemon__game_indices",
122 "pokemon__forms",
123 "pokemon__abilities",

Callers

nothing calls this directly

Calls 6

SinglePagePaginatorClass · 0.90
rest_api_sourceFunction · 0.90
assert_load_infoFunction · 0.90
load_table_countsFunction · 0.90
setup_pipelineMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected