-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: populate context from config #452
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"data_pack": { | ||
"name": "My Data Pack", | ||
"description": "a data pack", | ||
"pack_format": 6, | ||
"supported_formats": [0,6] | ||
}, | ||
"resource_pack": { | ||
"name": "My Resource Pack", | ||
"description": "a resource pack", | ||
"pack_format": 10, | ||
"supported_formats": { | ||
"min_inclusive": 10, | ||
"max_inclusive": 20 | ||
} | ||
}, | ||
"pipeline": ["mcmeta"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from beet import Context | ||
|
||
|
||
def beet_default(ctx: Context): | ||
all = [ | ||
f"{ctx.data.mcmeta.data}", | ||
f"{ctx.assets.mcmeta.data}", | ||
] | ||
ctx.meta["pytest"] = "\n".join(all) + "\n" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"data_pack": { | ||
"name": "My Data Pack", | ||
"description": "a data pack", | ||
"pack_format": 6, | ||
"supported_formats": [0,6] | ||
}, | ||
"resource_pack": { | ||
"name": "My Resource Pack", | ||
"description": "a resource pack", | ||
"pack_format": 10, | ||
"supported_formats": { | ||
"min_inclusive": 10, | ||
"max_inclusive": 20 | ||
} | ||
}, | ||
"pipeline": ["pack_info"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from beet import Context | ||
|
||
|
||
def beet_default(ctx: Context): | ||
all = [ | ||
f"{ctx.data.name}", | ||
f"{ctx.data.description}", | ||
f"{ctx.data.pack_format}", | ||
f"{ctx.data.supported_formats}", | ||
f"{ctx.assets.name}", | ||
f"{ctx.assets.description}", | ||
f"{ctx.assets.pack_format}", | ||
f"{ctx.assets.supported_formats}", | ||
] | ||
ctx.meta["pytest"] = "\n".join(all) + "\n" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"author": "somebody", | ||
"version": "1.2.3", | ||
"name": "BEET", | ||
"id": "beet", | ||
"description": "a beet project", | ||
"minecraft": "1.19", | ||
"pipeline": ["project_info"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from beet import Context | ||
|
||
|
||
def beet_default(ctx: Context): | ||
all = [ | ||
f"{ctx.minecraft_version}", | ||
f"{ctx.project_author}", | ||
f"{ctx.project_description}", | ||
f"{ctx.project_id}", | ||
f"{ctx.project_name}", | ||
f"{ctx.project_version}", | ||
] | ||
ctx.meta["pytest"] = "\n".join(all) + "\n" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{'pack': {'pack_format': 6, 'description': 'a data pack', 'supported_formats': [0, 6]}} | ||
{'pack': {'pack_format': 10, 'description': 'a resource pack', 'supported_formats': {'min_inclusive': 10, 'max_inclusive': 20}}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
My Data Pack | ||
a data pack | ||
6 | ||
[0, 6] | ||
My Resource Pack | ||
a resource pack | ||
10 | ||
{'min_inclusive': 10, 'max_inclusive': 20} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
1.19 | ||
somebody | ||
a beet project | ||
beet | ||
BEET | ||
1.2.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
|
||
import pytest | ||
from pytest_insta import SnapshotFixture | ||
|
||
from beet import run_beet | ||
|
||
|
||
@pytest.mark.parametrize("directory", os.listdir("tests/ctx_config_examples")) | ||
def test_examples(snapshot: SnapshotFixture, directory: str): | ||
with run_beet(directory=f"tests/ctx_config_examples/{directory}") as ctx: | ||
assert snapshot() == f'{ctx.meta["pytest"]}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here instead of creating a snapshot from f'{ctx.meta["pytest"]}', it's maybe better to it like this : with run_beet(directory=f"tests/ctx_config_examples/{directory}") as ctx:
assert snapshot() == {
"minecraft_version": ctx.minecraft_version,
"project_author": ctx.project_author,
# (... with all other parts of the config transferred to the ctx variable )
} This would eliminate the need of per directory plugin, and the need of a the new subfolder There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bug (#451) only occurs when trying to read the values in a plugin, so checking it in the test function will give a different result. Basically, the problem is that plugins can't access the info because it's populated only when building the pack (i.e. after running the plugins). Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh i see, i don't like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that was the main reason I wanted a review; the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theses changes are good