Skip to content

feat(Test data): Update test data with the Evaluation Context spec - #12

Merged
khvn26 merged 8 commits into
feat/context-valuesfrom
feat/context-values-intensifies
Oct 2, 2025
Merged

feat(Test data): Update test data with the Evaluation Context spec#12
khvn26 merged 8 commits into
feat/context-valuesfrom
feat/context-values-intensifies

Conversation

@emyller

@emylleremyller commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

Contributes to #11

This updates test data to match expected formats in tests:

...
// Replaces "identities_and_responses""test_cases": [
{
"context": {/* EvaluationContext spec */},
"result": {/* EvaluationResult spec */}
},
// ...
]

JSON data was generated by flagsmith-engine tests, with the following patch applied:

diff --git tests/engine_tests/test_engine.py tests/engine_tests/test_engine.py
index 426abf4..ed84b26 100644
--- tests/engine_tests/test_engine.py+++ tests/engine_tests/test_engine.py@@ -144,29 +144,28 @@ TEST_CASES = list(
)
-@pytest.mark.parametrize(- "context, response",- TEST_CASES,-)+# @pytest.mark.parametrize(+# "context, response",+# TEST_CASES,+# )
def test_engine(
- context: EvaluationContext,- response: APIResponse,- mocker: MockerFixture,+ # context: EvaluationContext,+ # response: APIResponse,+ # mocker: MockerFixture,
) -> None:
- # When- engine_response = get_evaluation_result(context)-- # Then- assert {flag["feature_key"]: flag for flag in engine_response["flags"]} == {- (feature_key := str(flag["feature"]["id"])): {- "name": flag["feature"]["name"],- "feature_key": feature_key,- "enabled": flag["enabled"],- "value": flag["feature_state_value"],- "reason": mocker.ANY,- }- for flag in response["flags"]- }+ test_cases = []+ for context, orig_response in TEST_CASES:+ engine_response = get_evaluation_result(context)+ test_cases.append({+ "context": context,+ "result": engine_response,+ })++ data_path = MODULE_PATH / "engine-test-data/data/environment_n9fbf9h3v4fFgH3U3ngWhb.json"+ contents = json.loads(data_path.read_text())+ del contents["identities_and_responses"]+ contents["test_cases"] = test_cases+ data_path.write_text(json.dumps(contents, sort_keys=True, indent=2))
@pytest.mark.benchmark

@emyller
emyller marked this pull request as ready for review September 17, 2025 23:23
@emyller
emyllerforce-pushed the feat/context-values-intensifies branch from 9cabb24 to 5e7c413CompareSeptember 17, 2025 23:41
@emyller
emyller marked this pull request as draft September 18, 2025 18:54
@emylleremyller self-assigned this Sep 18, 2025
@emyller
emyllerforce-pushed the feat/context-values-intensifies branch from 54c01a0 to df9a017CompareSeptember 18, 2025 19:52
@emyller
emyller marked this pull request as ready for review September 18, 2025 19:55
@emyller
emyller marked this pull request as draft September 18, 2025 22:12
@emyller

emyller commented Sep 18, 2025

Copy link
Copy Markdown
ContributorAuthor

@khvn26 Do we want to adjust responses, as per this snippet, to comply to the EvaluationResult spec?

@khvn26

Copy link
Copy Markdown
Member

Yes, let's map to EvaluationResult. This in fact part a requirement as per #11.

@emyller
emyller marked this pull request as ready for review September 19, 2025 20:40
Comment threadreadme.md Outdated
@khvn26
khvn26 merged commit 5139edd into feat/context-valuesOct 2, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@emyller@khvn26@Zaimwa9