Skip to content

Commit 0716659

Browse files
committed
tests
1 parent fcdf964 commit 0716659

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

tests/unit/sdk/test_client.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,17 @@ async def test_method_get_user_permissions(clients, mock_query_infrahub_user, cl
128128
@pytest.mark.parametrize("client_type", client_types)
129129
async def test_method_all_with_limit(clients, mock_query_repository_page1_2, client_type):
130130
if client_type == "standard":
131-
repos = await clients.standard.all(kind="CoreRepository", limit=3)
132-
assert len(clients.standard.store._store["CoreRepository"]) == 3
133-
134131
repos = await clients.standard.all(kind="CoreRepository", populate_store=False, limit=3)
135132
assert not clients.standard.store._store["CoreRepository"]
136-
else:
137-
repos = clients.sync.all(kind="CoreRepository", limit=3)
138-
assert len(clients.sync.store._store["CoreRepository"]) == 3
139133

134+
repos = await clients.standard.all(kind="CoreRepository", limit=3)
135+
assert len(clients.standard.store._store["CoreRepository"]) == 3
136+
else:
140137
repos = clients.sync.all(kind="CoreRepository", populate_store=False, limit=3)
141138
assert not clients.sync.store._store["CoreRepository"]
142139

140+
repos = clients.sync.all(kind="CoreRepository", limit=3)
141+
assert len(clients.sync.store._store["CoreRepository"]) == 3
143142
assert len(repos) == 3
144143

145144

@@ -148,18 +147,18 @@ async def test_method_all_multiple_pages(
148147
clients, mock_query_repository_page1_2, mock_query_repository_page2_2, client_type
149148
):
150149
if client_type == "standard":
151-
repos = await clients.standard.all(kind="CoreRepository")
152-
assert len(clients.standard.store._store["CoreRepository"]) == 5
153-
154150
repos = await clients.standard.all(kind="CoreRepository", populate_store=False)
155151
assert not clients.standard.store._store["CoreRepository"]
156-
else:
157-
repos = clients.sync.all(kind="CoreRepository")
158-
assert len(clients.sync.store._store["CoreRepository"]) == 5
159152

153+
repos = await clients.standard.all(kind="CoreRepository")
154+
assert len(clients.standard.store._store["CoreRepository"]) == 5
155+
else:
160156
repos = clients.sync.all(kind="CoreRepository", populate_store=False)
161157
assert not clients.sync.store._store["CoreRepository"]
162158

159+
repos = clients.sync.all(kind="CoreRepository")
160+
assert len(clients.sync.store._store["CoreRepository"]) == 5
161+
163162
assert len(repos) == 5
164163

165164

@@ -168,36 +167,36 @@ async def test_method_all_batching(
168167
clients, mock_query_location_batch_count, mock_query_location_batch, client_type, use_parallel
169168
):
170169
if client_type == "standard":
171-
locations = await clients.standard.all(kind="BuiltinLocation", parallel=use_parallel)
172-
assert len(clients.standard.store._store["BuiltinLocation"]) == 30
173-
174170
locations = await clients.standard.all(kind="BuiltinLocation", populate_store=False, parallel=use_parallel)
175171
assert not clients.standard.store._store["BuiltinLocation"]
176-
else:
177-
locations = clients.sync.all(kind="BuiltinLocation", parallel=use_parallel)
178-
assert len(clients.sync.store._store["BuiltinLocation"]) == 30
179172

173+
locations = await clients.standard.all(kind="BuiltinLocation", parallel=use_parallel)
174+
assert len(clients.standard.store._store["BuiltinLocation"]) == 30
175+
else:
180176
locations = clients.sync.all(kind="BuiltinLocation", populate_store=False, parallel=use_parallel)
181177
assert not clients.sync.store._store["BuiltinLocation"]
182178

179+
locations = clients.sync.all(kind="BuiltinLocation", parallel=use_parallel)
180+
assert len(clients.sync.store._store["BuiltinLocation"]) == 30
181+
183182
assert len(locations) == 30
184183

185184

186185
@pytest.mark.parametrize("client_type", client_types)
187186
async def test_method_all_single_page(clients, mock_query_repository_page1_1, client_type):
188187
if client_type == "standard":
189-
repos = await clients.standard.all(kind="CoreRepository")
190-
assert len(clients.standard.store._store["CoreRepository"]) == 2
191-
192188
repos = await clients.standard.all(kind="CoreRepository", populate_store=False)
193189
assert not clients.standard.store._store["CoreRepository"]
194-
else:
195-
repos = clients.sync.all(kind="CoreRepository")
196-
assert len(clients.sync.store._store["CoreRepository"]) == 2
197190

191+
repos = await clients.standard.all(kind="CoreRepository")
192+
assert len(clients.standard.store._store["CoreRepository"]) == 2
193+
else:
198194
repos = clients.sync.all(kind="CoreRepository", populate_store=False)
199195
assert not clients.sync.store._store["CoreRepository"]
200196

197+
repos = clients.sync.all(kind="CoreRepository")
198+
assert len(clients.sync.store._store["CoreRepository"]) == 2
199+
201200
assert len(repos) == 2
202201

203202

0 commit comments

Comments
 (0)