Skip to content

Commit 3eb3dee

Browse files
teksgadomski
andauthored
993 progress: convert test_version.py & test_item.py to pytest (#1516)
* 993 convert test_version.py to pytest * 993 convert test_item.py to pytest * 993 apply pre-commit fixes * 993 replace function with fixture --------- Co-authored-by: Pete Gadomski <[email protected]>
1 parent 69e2cb0 commit 3eb3dee

File tree

4 files changed

+386
-416
lines changed

4 files changed

+386
-416
lines changed

Diff for: tests/cassettes/test_item/ItemTest.test_null_geometry.yaml renamed to tests/cassettes/test_item/test_null_geometry.yaml

+48-50
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interactions:
77
Host:
88
- schemas.stacspec.org
99
User-Agent:
10-
- Python-urllib/3.12
10+
- Python-urllib/3.13
1111
method: GET
1212
uri: https://schemas.stacspec.org/v1.0.0-beta.2/item-spec/json-schema/item.json
1313
response:
@@ -99,7 +99,7 @@ interactions:
9999
Content-Type:
100100
- application/json; charset=utf-8
101101
Date:
102-
- Thu, 23 Jan 2025 15:04:21 GMT
102+
- Sun, 02 Feb 2025 00:00:39 GMT
103103
ETag:
104104
- '"66e1651c-147c"'
105105
Last-Modified:
@@ -111,19 +111,19 @@ interactions:
111111
Via:
112112
- 1.1 varnish
113113
X-Cache:
114-
- MISS
114+
- HIT
115115
X-Cache-Hits:
116116
- '0'
117117
X-Fastly-Request-ID:
118-
- eee882ae55a7f40729d77f3d500a84bed4c637d0
118+
- 9a54b2c2e8d8dfda667d69d0dd28acd3c223b4c7
119119
X-GitHub-Request-Id:
120-
- 7F28:34A10D:FF6968:11D3377:67925A75
120+
- 6B5F:16F8:3EC0E8:470F4B:679E5948
121121
X-Served-By:
122-
- cache-den-kden1300051-DEN
122+
- cache-bos4633-BOS
123123
X-Timer:
124-
- S1737644661.145511,VS0,VE59
124+
- S1738454440.623801,VS0,VE20
125125
expires:
126-
- Thu, 23 Jan 2025 15:14:21 GMT
126+
- Sat, 01 Feb 2025 17:36:33 GMT
127127
x-proxy-cache:
128128
- MISS
129129
status:
@@ -137,7 +137,7 @@ interactions:
137137
Host:
138138
- schemas.stacspec.org
139139
User-Agent:
140-
- Python-urllib/3.12
140+
- Python-urllib/3.13
141141
method: GET
142142
uri: https://schemas.stacspec.org/v1.0.0-beta.2/item-spec/json-schema/basics.json
143143
response:
@@ -166,7 +166,7 @@ interactions:
166166
Content-Type:
167167
- application/json; charset=utf-8
168168
Date:
169-
- Thu, 23 Jan 2025 15:04:21 GMT
169+
- Sun, 02 Feb 2025 00:00:39 GMT
170170
ETag:
171171
- '"66e1651c-21c"'
172172
Last-Modified:
@@ -178,19 +178,19 @@ interactions:
178178
Via:
179179
- 1.1 varnish
180180
X-Cache:
181-
- MISS
181+
- HIT
182182
X-Cache-Hits:
183183
- '0'
184184
X-Fastly-Request-ID:
185-
- 24282bdf85a8fde571d18d0a3007d5cf6bf30fcb
185+
- 8f6c3b198c4c026542ea5cc5b46485cfce14313c
186186
X-GitHub-Request-Id:
187-
- 5ED4:12DF28:F44C6C:1121586:67925A75
187+
- 7D47:4AAAC:67C965:716773:679E5948
188188
X-Served-By:
189-
- cache-den-kden1300073-DEN
189+
- cache-bos4643-BOS
190190
X-Timer:
191-
- S1737644661.228637,VS0,VE68
191+
- S1738454440.712740,VS0,VE30
192192
expires:
193-
- Thu, 23 Jan 2025 15:14:21 GMT
193+
- Sat, 01 Feb 2025 17:36:33 GMT
194194
x-origin-cache:
195195
- HIT
196196
x-proxy-cache:
@@ -206,7 +206,7 @@ interactions:
206206
Host:
207207
- schemas.stacspec.org
208208
User-Agent:
209-
- Python-urllib/3.12
209+
- Python-urllib/3.13
210210
method: GET
211211
uri: https://schemas.stacspec.org/v1.0.0-beta.2/item-spec/json-schema/datetime.json
212212
response:
@@ -265,7 +265,7 @@ interactions:
265265
Content-Type:
266266
- application/json; charset=utf-8
267267
Date:
268-
- Thu, 23 Jan 2025 15:04:21 GMT
268+
- Sun, 02 Feb 2025 00:00:39 GMT
269269
ETag:
270270
- '"66e1651c-a82"'
271271
Last-Modified:
@@ -277,19 +277,19 @@ interactions:
277277
Via:
278278
- 1.1 varnish
279279
X-Cache:
280-
- MISS
280+
- HIT
281281
X-Cache-Hits:
282282
- '0'
283283
X-Fastly-Request-ID:
284-
- a29e86e905de4ad9406e730b8f75d8d9fc0e363d
284+
- 530a4436422927e3d78506b58f78887510928f7f
285285
X-GitHub-Request-Id:
286-
- 5488:230B9F:B893E:CFA99:67925A75
286+
- 97C0:A1EF3:5E972D:68288C:679E5949
287287
X-Served-By:
288-
- cache-den-kden1300042-DEN
288+
- cache-bos4655-BOS
289289
X-Timer:
290-
- S1737644661.327324,VS0,VE57
290+
- S1738454440.811790,VS0,VE30
291291
expires:
292-
- Thu, 23 Jan 2025 15:14:21 GMT
292+
- Sat, 01 Feb 2025 17:36:33 GMT
293293
x-proxy-cache:
294294
- MISS
295295
status:
@@ -303,7 +303,7 @@ interactions:
303303
Host:
304304
- schemas.stacspec.org
305305
User-Agent:
306-
- Python-urllib/3.12
306+
- Python-urllib/3.13
307307
method: GET
308308
uri: https://schemas.stacspec.org/v1.0.0-beta.2/item-spec/json-schema/instrument.json
309309
response:
@@ -334,7 +334,7 @@ interactions:
334334
Content-Type:
335335
- application/json; charset=utf-8
336336
Date:
337-
- Thu, 23 Jan 2025 15:04:21 GMT
337+
- Sun, 02 Feb 2025 00:00:39 GMT
338338
ETag:
339339
- '"66e1651c-2a2"'
340340
Last-Modified:
@@ -346,21 +346,19 @@ interactions:
346346
Via:
347347
- 1.1 varnish
348348
X-Cache:
349-
- MISS
349+
- HIT
350350
X-Cache-Hits:
351351
- '0'
352352
X-Fastly-Request-ID:
353-
- dd7f2955fbdd7a5b0b24cac94bac85eadaea1608
353+
- efcbb9e72539f153ef7cf2b7377c273d12c96c9e
354354
X-GitHub-Request-Id:
355-
- 802D:338B06:10BB8A9:1298392:67925A75
355+
- FA0A:15A6D:5C46DD:65DCD4:679E5947
356356
X-Served-By:
357-
- cache-den-kden1300065-DEN
357+
- cache-bos4692-BOS
358358
X-Timer:
359-
- S1737644661.410596,VS0,VE58
359+
- S1738454440.905646,VS0,VE41
360360
expires:
361-
- Thu, 23 Jan 2025 15:14:21 GMT
362-
x-origin-cache:
363-
- HIT
361+
- Sat, 01 Feb 2025 17:36:33 GMT
364362
x-proxy-cache:
365363
- MISS
366364
status:
@@ -374,7 +372,7 @@ interactions:
374372
Host:
375373
- schemas.stacspec.org
376374
User-Agent:
377-
- Python-urllib/3.12
375+
- Python-urllib/3.13
378376
method: GET
379377
uri: https://schemas.stacspec.org/v1.0.0-beta.2/item-spec/json-schema/licensing.json
380378
response:
@@ -400,7 +398,7 @@ interactions:
400398
Content-Type:
401399
- application/json; charset=utf-8
402400
Date:
403-
- Thu, 23 Jan 2025 15:04:21 GMT
401+
- Sun, 02 Feb 2025 00:00:40 GMT
404402
ETag:
405403
- '"66e1651c-135"'
406404
Last-Modified:
@@ -412,19 +410,19 @@ interactions:
412410
Via:
413411
- 1.1 varnish
414412
X-Cache:
415-
- MISS
413+
- HIT
416414
X-Cache-Hits:
417415
- '0'
418416
X-Fastly-Request-ID:
419-
- 2b8fd8778031ec89e594e7017d5111a507d66dfc
417+
- 3d703898d330148032f27df7d9d46c65c819285e
420418
X-GitHub-Request-Id:
421-
- D377:3405BB:10C72BA:12A3CD2:67925A75
419+
- 085E:1C811A:56FD1C:609622:679E5949
422420
X-Served-By:
423-
- cache-den-kden1300032-DEN
421+
- cache-bos4624-BOS
424422
X-Timer:
425-
- S1737644661.495593,VS0,VE54
423+
- S1738454440.007807,VS0,VE27
426424
expires:
427-
- Thu, 23 Jan 2025 15:14:21 GMT
425+
- Sat, 01 Feb 2025 17:36:33 GMT
428426
x-origin-cache:
429427
- HIT
430428
x-proxy-cache:
@@ -440,7 +438,7 @@ interactions:
440438
Host:
441439
- schemas.stacspec.org
442440
User-Agent:
443-
- Python-urllib/3.12
441+
- Python-urllib/3.13
444442
method: GET
445443
uri: https://schemas.stacspec.org/v1.0.0-beta.2/item-spec/json-schema/provider.json
446444
response:
@@ -476,7 +474,7 @@ interactions:
476474
Content-Type:
477475
- application/json; charset=utf-8
478476
Date:
479-
- Thu, 23 Jan 2025 15:04:21 GMT
477+
- Sun, 02 Feb 2025 00:00:40 GMT
480478
ETag:
481479
- '"66e1651c-40e"'
482480
Last-Modified:
@@ -488,19 +486,19 @@ interactions:
488486
Via:
489487
- 1.1 varnish
490488
X-Cache:
491-
- MISS
489+
- HIT
492490
X-Cache-Hits:
493491
- '0'
494492
X-Fastly-Request-ID:
495-
- 84d8905f4abd1401e3d76535680a6bda88fa0568
493+
- 01a1b60753cc5e73cb47bd5d87093ead8c9e73d8
496494
X-GitHub-Request-Id:
497-
- 538F:1011A9:1037FFE:1214BBF:67925A75
495+
- 6370:26E82C:5B4B43:64E477:679E5947
498496
X-Served-By:
499-
- cache-den-kden1300062-DEN
497+
- cache-bos4647-BOS
500498
X-Timer:
501-
- S1737644662.570305,VS0,VE54
499+
- S1738454440.107510,VS0,VE29
502500
expires:
503-
- Thu, 23 Jan 2025 15:14:21 GMT
501+
- Sat, 01 Feb 2025 17:36:33 GMT
504502
x-origin-cache:
505503
- HIT
506504
x-proxy-cache:

Diff for: tests/conftest.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# TODO move all test case code to this file
22

3+
import json
34
import shutil
45
import uuid
56
from datetime import datetime
67
from pathlib import Path
8+
from typing import Any
79

810
import pytest
911

@@ -61,6 +63,14 @@ def get_data_file(rel_path: str) -> str:
6163
return str(here / "data-files" / rel_path)
6264

6365

66+
@pytest.fixture
67+
def sample_item_dict() -> dict[str, Any]:
68+
m = TestCases.get_path("data-files/item/sample-item.json")
69+
with open(m) as f:
70+
item_dict: dict[str, Any] = json.load(f)
71+
return item_dict
72+
73+
6474
@pytest.fixture
6575
def sample_item() -> Item:
6676
return Item.from_file(TestCases.get_path("data-files/item/sample-item.json"))

0 commit comments

Comments
 (0)