Skip to content

Commit ba75eba

Browse files
chore: add tests for WithTransformation methods (generated)
algolia/api-clients-automation#4936 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
1 parent b2b0c16 commit ba75eba

File tree

10 files changed

+84
-28
lines changed

10 files changed

+84
-28
lines changed

algoliasearch/abtesting/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ def create_with_config(
103103
if transporter is None:
104104
transporter = Transporter(config)
105105

106-
return AbtestingClient(
106+
client = AbtestingClient(
107107
app_id=config.app_id,
108108
api_key=config.api_key,
109109
region=config.region,
110110
transporter=transporter,
111111
config=config,
112112
)
113113

114+
return client
115+
114116
async def __aenter__(self) -> Self:
115117
return self
116118

@@ -953,14 +955,16 @@ def create_with_config(
953955
if transporter is None:
954956
transporter = TransporterSync(config)
955957

956-
return AbtestingClientSync(
958+
client = AbtestingClientSync(
957959
app_id=config.app_id,
958960
api_key=config.api_key,
959961
region=config.region,
960962
transporter=transporter,
961963
config=config,
962964
)
963965

966+
return client
967+
964968
def __enter__(self) -> Self:
965969
return self
966970

algoliasearch/analytics/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,16 @@ def create_with_config(
117117
if transporter is None:
118118
transporter = Transporter(config)
119119

120-
return AnalyticsClient(
120+
client = AnalyticsClient(
121121
app_id=config.app_id,
122122
api_key=config.api_key,
123123
region=config.region,
124124
transporter=transporter,
125125
config=config,
126126
)
127127

128+
return client
129+
128130
async def __aenter__(self) -> Self:
129131
return self
130132

@@ -3157,14 +3159,16 @@ def create_with_config(
31573159
if transporter is None:
31583160
transporter = TransporterSync(config)
31593161

3160-
return AnalyticsClientSync(
3162+
client = AnalyticsClientSync(
31613163
app_id=config.app_id,
31623164
api_key=config.api_key,
31633165
region=config.region,
31643166
transporter=transporter,
31653167
config=config,
31663168
)
31673169

3170+
return client
3171+
31683172
def __enter__(self) -> Self:
31693173
return self
31703174

algoliasearch/composition/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ def create_with_config(
9898
if transporter is None:
9999
transporter = Transporter(config)
100100

101-
return CompositionClient(
101+
client = CompositionClient(
102102
app_id=config.app_id,
103103
api_key=config.api_key,
104104
transporter=transporter,
105105
config=config,
106106
)
107107

108+
return client
109+
108110
async def __aenter__(self) -> Self:
109111
return self
110112

@@ -356,13 +358,15 @@ def create_with_config(
356358
if transporter is None:
357359
transporter = TransporterSync(config)
358360

359-
return CompositionClientSync(
361+
client = CompositionClientSync(
360362
app_id=config.app_id,
361363
api_key=config.api_key,
362364
transporter=transporter,
363365
config=config,
364366
)
365367

368+
return client
369+
366370
def __enter__(self) -> Self:
367371
return self
368372

algoliasearch/ingestion/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,16 @@ def create_with_config(
164164
if transporter is None:
165165
transporter = Transporter(config)
166166

167-
return IngestionClient(
167+
client = IngestionClient(
168168
app_id=config.app_id,
169169
api_key=config.api_key,
170170
region=config.region,
171171
transporter=transporter,
172172
config=config,
173173
)
174174

175+
return client
176+
175177
async def __aenter__(self) -> Self:
176178
return self
177179

@@ -5172,14 +5174,16 @@ def create_with_config(
51725174
if transporter is None:
51735175
transporter = TransporterSync(config)
51745176

5175-
return IngestionClientSync(
5177+
client = IngestionClientSync(
51765178
app_id=config.app_id,
51775179
api_key=config.api_key,
51785180
region=config.region,
51795181
transporter=transporter,
51805182
config=config,
51815183
)
51825184

5185+
return client
5186+
51835187
def __enter__(self) -> Self:
51845188
return self
51855189

algoliasearch/insights/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ def create_with_config(
9494
if transporter is None:
9595
transporter = Transporter(config)
9696

97-
return InsightsClient(
97+
client = InsightsClient(
9898
app_id=config.app_id,
9999
api_key=config.api_key,
100100
region=config.region,
101101
transporter=transporter,
102102
config=config,
103103
)
104104

105+
return client
106+
105107
async def __aenter__(self) -> Self:
106108
return self
107109

@@ -642,14 +644,16 @@ def create_with_config(
642644
if transporter is None:
643645
transporter = TransporterSync(config)
644646

645-
return InsightsClientSync(
647+
client = InsightsClientSync(
646648
app_id=config.app_id,
647649
api_key=config.api_key,
648650
region=config.region,
649651
transporter=transporter,
650652
config=config,
651653
)
652654

655+
return client
656+
653657
def __enter__(self) -> Self:
654658
return self
655659

algoliasearch/monitoring/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ def create_with_config(
102102
if transporter is None:
103103
transporter = Transporter(config)
104104

105-
return MonitoringClient(
105+
client = MonitoringClient(
106106
app_id=config.app_id,
107107
api_key=config.api_key,
108108
transporter=transporter,
109109
config=config,
110110
)
111111

112+
return client
113+
112114
async def __aenter__(self) -> Self:
113115
return self
114116

@@ -978,13 +980,15 @@ def create_with_config(
978980
if transporter is None:
979981
transporter = TransporterSync(config)
980982

981-
return MonitoringClientSync(
983+
client = MonitoringClientSync(
982984
app_id=config.app_id,
983985
api_key=config.api_key,
984986
transporter=transporter,
985987
config=config,
986988
)
987989

990+
return client
991+
988992
def __enter__(self) -> Self:
989993
return self
990994

algoliasearch/personalization/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,16 @@ def create_with_config(
9999
if transporter is None:
100100
transporter = Transporter(config)
101101

102-
return PersonalizationClient(
102+
client = PersonalizationClient(
103103
app_id=config.app_id,
104104
api_key=config.api_key,
105105
region=config.region,
106106
transporter=transporter,
107107
config=config,
108108
)
109109

110+
return client
111+
110112
async def __aenter__(self) -> Self:
111113
return self
112114

@@ -753,14 +755,16 @@ def create_with_config(
753755
if transporter is None:
754756
transporter = TransporterSync(config)
755757

756-
return PersonalizationClientSync(
758+
client = PersonalizationClientSync(
757759
app_id=config.app_id,
758760
api_key=config.api_key,
759761
region=config.region,
760762
transporter=transporter,
761763
config=config,
762764
)
763765

766+
return client
767+
764768
def __enter__(self) -> Self:
765769
return self
766770

algoliasearch/query_suggestions/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ def create_with_config(
101101
if transporter is None:
102102
transporter = Transporter(config)
103103

104-
return QuerySuggestionsClient(
104+
client = QuerySuggestionsClient(
105105
app_id=config.app_id,
106106
api_key=config.api_key,
107107
region=config.region,
108108
transporter=transporter,
109109
config=config,
110110
)
111111

112+
return client
113+
112114
async def __aenter__(self) -> Self:
113115
return self
114116

@@ -921,14 +923,16 @@ def create_with_config(
921923
if transporter is None:
922924
transporter = TransporterSync(config)
923925

924-
return QuerySuggestionsClientSync(
926+
client = QuerySuggestionsClientSync(
925927
app_id=config.app_id,
926928
api_key=config.api_key,
927929
region=config.region,
928930
transporter=transporter,
929931
config=config,
930932
)
931933

934+
return client
935+
932936
def __enter__(self) -> Self:
933937
return self
934938

algoliasearch/recommend/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ def create_with_config(
103103
if transporter is None:
104104
transporter = Transporter(config)
105105

106-
return RecommendClient(
106+
client = RecommendClient(
107107
app_id=config.app_id,
108108
api_key=config.api_key,
109109
transporter=transporter,
110110
config=config,
111111
)
112112

113+
return client
114+
113115
async def __aenter__(self) -> Self:
114116
return self
115117

@@ -1088,13 +1090,15 @@ def create_with_config(
10881090
if transporter is None:
10891091
transporter = TransporterSync(config)
10901092

1091-
return RecommendClientSync(
1093+
client = RecommendClientSync(
10921094
app_id=config.app_id,
10931095
api_key=config.api_key,
10941096
transporter=transporter,
10951097
config=config,
10961098
)
10971099

1100+
return client
1101+
10981102
def __enter__(self) -> Self:
10991103
return self
11001104

algoliasearch/search/client.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ def __init__(
147147
config = SearchConfig(transporter.config.app_id, transporter.config.api_key)
148148
elif config is None:
149149
config = SearchConfig(app_id, api_key)
150-
elif config.region is not None:
151-
self._ingestion_transporter = IngestionClient.create_with_config(
152-
IngestionConfig(config.app_id, config.api_key, config.region)
153-
)
154150

155151
self._config = config
156152
self._request_options = RequestOptions(config)
@@ -179,13 +175,27 @@ def create_with_config(
179175
if transporter is None:
180176
transporter = Transporter(config)
181177

182-
return SearchClient(
178+
client = SearchClient(
183179
app_id=config.app_id,
184180
api_key=config.api_key,
185181
transporter=transporter,
186182
config=config,
187183
)
188184

185+
if config.region is not None:
186+
ingestion_config = IngestionConfig(
187+
config.app_id, config.api_key, config.region
188+
)
189+
190+
if config.hosts is not None:
191+
ingestion_config.hosts = config.hosts
192+
193+
client._ingestion_transporter = IngestionClient.create_with_config(
194+
ingestion_config
195+
)
196+
197+
return client
198+
189199
async def __aenter__(self) -> Self:
190200
return self
191201

@@ -5289,10 +5299,6 @@ def __init__(
52895299
config = SearchConfig(transporter.config.app_id, transporter.config.api_key)
52905300
elif config is None:
52915301
config = SearchConfig(app_id, api_key)
5292-
elif config.region is not None:
5293-
self._ingestion_transporter = IngestionClientSync.create_with_config(
5294-
IngestionConfig(config.app_id, config.api_key, config.region)
5295-
)
52965302

52975303
self._config = config
52985304
self._request_options = RequestOptions(config)
@@ -5321,13 +5327,27 @@ def create_with_config(
53215327
if transporter is None:
53225328
transporter = TransporterSync(config)
53235329

5324-
return SearchClientSync(
5330+
client = SearchClientSync(
53255331
app_id=config.app_id,
53265332
api_key=config.api_key,
53275333
transporter=transporter,
53285334
config=config,
53295335
)
53305336

5337+
if config.region is not None:
5338+
ingestion_config = IngestionConfig(
5339+
config.app_id, config.api_key, config.region
5340+
)
5341+
5342+
if config.hosts is not None:
5343+
ingestion_config.hosts = config.hosts
5344+
5345+
client._ingestion_transporter = IngestionClientSync.create_with_config(
5346+
ingestion_config
5347+
)
5348+
5349+
return client
5350+
53315351
def __enter__(self) -> Self:
53325352
return self
53335353

0 commit comments

Comments
 (0)