Skip to content

Commit 37e72a7

Browse files
authored
fix: package content tests (#67)
We have supported the `exists` / `not_exists` for a while now, also in other fields than `tests.package_content.files`.
1 parent 1656431 commit 37e72a7

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

conda_recipe_v2_schema/model.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ class DownstreamTestElement(StrictBaseModel):
500500
)
501501

502502

503-
class FileChecks(StrictBaseModel):
503+
class FileExistenceCheck(StrictBaseModel):
504504
exists: ConditionalList[NonEmptyStr] | None = Field(
505505
default=[],
506506
description="Files or glob patterns that must exist anywhere inside the package.",
@@ -511,20 +511,24 @@ class FileChecks(StrictBaseModel):
511511
)
512512

513513

514+
# Type alias for file content test fields - can be either simple list or existence check dict
515+
FileContentTest = ConditionalList[NonEmptyStr] | FileExistenceCheck
516+
517+
514518
class PackageContentTestInner(StrictBaseModel):
515-
files: ConditionalList[NonEmptyStr] | FileChecks | None = Field(
519+
files: FileContentTest | None = Field(
516520
default=None,
517521
description="Files expectations for the whole package. Can be a list of files/globs or an object with exists/not_exists.",
518522
)
519-
include: ConditionalList[NonEmptyStr] | None = Field(
523+
include: FileContentTest | None = Field(
520524
default=[],
521525
description="Files that should be in the `include/` folder of the package. This folder is found under `$PREFIX/include` on Unix and `$PREFIX/Library/include` on Windows.",
522526
)
523-
site_packages: ConditionalList[NonEmptyStr] | None = Field(
527+
site_packages: FileContentTest | None = Field(
524528
default=[],
525529
description="Files that should be in the `site-packages/` folder of the package. This folder is found under `$PREFIX/lib/pythonX.Y/site-packages` on Unix and `$PREFIX/Lib/site-packages` on Windows.",
526530
)
527-
bin: ConditionalList[NonEmptyStr] | None = Field(
531+
bin: FileContentTest | None = Field(
528532
default=[],
529533
description="Files that should be in the `bin/` folder of the package. This folder is found under `$PREFIX/bin` on Unix. On Windows this searches for files in `%PREFIX`, `%PREFIX%/bin`, `%PREFIX%/Scripts`, `%PREFIX%/Library/bin`, `%PREFIX/Library/usr/bin` and `%PREFIX/Library/mingw-w64/bin`.",
530534
)

schema.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@
12141214
"title": "DynamicLinking",
12151215
"type": "object"
12161216
},
1217-
"FileChecks": {
1217+
"FileExistenceCheck": {
12181218
"additionalProperties": false,
12191219
"properties": {
12201220
"exists": {
@@ -1280,7 +1280,7 @@
12801280
"title": "Not Exists"
12811281
}
12821282
},
1283-
"title": "FileChecks",
1283+
"title": "FileExistenceCheck",
12841284
"type": "object"
12851285
},
12861286
"FileScript": {
@@ -3002,7 +3002,7 @@
30023002
"type": "array"
30033003
},
30043004
{
3005-
"$ref": "#/$defs/FileChecks"
3005+
"$ref": "#/$defs/FileExistenceCheck"
30063006
},
30073007
{
30083008
"type": "null"
@@ -3035,6 +3035,9 @@
30353035
},
30363036
"type": "array"
30373037
},
3038+
{
3039+
"$ref": "#/$defs/FileExistenceCheck"
3040+
},
30383041
{
30393042
"type": "null"
30403043
}
@@ -3066,6 +3069,9 @@
30663069
},
30673070
"type": "array"
30683071
},
3072+
{
3073+
"$ref": "#/$defs/FileExistenceCheck"
3074+
},
30693075
{
30703076
"type": "null"
30713077
}
@@ -3097,6 +3103,9 @@
30973103
},
30983104
"type": "array"
30993105
},
3106+
{
3107+
"$ref": "#/$defs/FileExistenceCheck"
3108+
},
31003109
{
31013110
"type": "null"
31023111
}

0 commit comments

Comments
 (0)