Adapted skills:check and skills:install and added reusable tests - #966
jana-selva wants to merge 8 commits into
Conversation
|
❌ The last analysis has failed. |
| build.assert_called_once_with(nox_session, config) | ||
|
|
||
|
|
||
| def test_build_docs_command(config): |
There was a problem hiding this comment.
These kinds of tests are require lots of maintenance, if the code is changed.
9ec363f to
b81a6eb
Compare
|
Ah, please add a test for |
| lambda data: data["cases"][0]["expected"].update(must_not_include=[""]), | ||
| "case 0 must_not_include must contain non-empty strings", | ||
| ) | ||
| @pytest.fixture |
There was a problem hiding this comment.
This will actually load each time the fixture is called. If we wanted to do it once, we should set the scope.
| @pytest.fixture | |
| @pytest.fixture(scope="module") |
| "case 0 must_not_include must contain non-empty strings", | ||
| ) | ||
| @pytest.fixture | ||
| def eval_cases(self, skill_name): |
There was a problem hiding this comment.
Thanks! In general, this looks much cleaner.
I'll let you decide, but realized today that I think long-term it'd be better if we introduced a Pydantic model that we validate against. This way, we can share the model in the documentation (via the API) and link it where appropriate. Then, we can just validate against it in the tests. Below is just a mock up for it - I didn't evaluate it extensively or iterate on the names much
NonBlankString = Annotated[str, Field(pattern=r"\S")]
class ExpectedResponse(BaseModel):
model_config = ConfigDict(extra="forbid")
must_include: list[NonBlankString] = Field(min_length=1)
must_not_include: list[NonBlankString] = Field(min_length=1)
class EvalCase(BaseModel):
model_config = ConfigDict(extra="forbid")
id: NonBlankString
category: NonBlankString
prompt: NonBlankString
expected: ExpectedResponse
class PackagedSkillEvalCases(BaseModel):
model_config = ConfigDict(extra="forbid")
version: Literal[1]
skill: NonBlankString
cases: list[EvalCase] = Field(min_length=1)

Fixes #963
Checklist
Note: If any of the items in the checklist are not relevant to your PR, just check the box.
For any Pull Request
Is the following correct:
When Changes Were Made
Did you:
When Preparing a Release
Have you: