Skip to content

Commit 2006b8f

Browse files
feat(flagd-core): add disabled flag evaluation e2e BDD scenarios
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
1 parent daafd73 commit 2006b8f

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@disabled
2+
Feature: Disabled flag evaluation
3+
4+
# A flag with state=DISABLED resolves with reason=DISABLED and no value or
5+
# variant; the SDK returns the caller's code default.
6+
# Relates to: https://github.com/open-feature/flagd/issues/1965
7+
8+
Scenario Outline: Evaluating a disabled flag returns reason DISABLED and code default
9+
Given an evaluator
10+
And a <type>-flag with key "<key>" and a fallback value "<default>"
11+
When the flag was evaluated with details
12+
Then the resolved details value should be "<default>"
13+
And the reason should be "DISABLED"
14+
15+
Examples:
16+
| key | type | default |
17+
| disabled-boolean-flag | Boolean | false |
18+
| disabled-string-flag | String | bye |
19+
| disabled-integer-flag | Integer | 1 |
20+
| disabled-float-flag | Float | 0.1 |
21+
| disabled-object-flag | Object | {} |
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import json
2+
from pathlib import Path
3+
4+
import pytest
5+
from pytest_bdd import scenarios
6+
7+
from openfeature.contrib.tools.flagd.core import FlagdCore
8+
from openfeature.contrib.tools.flagd.testkit.steps import * # noqa: F403
9+
10+
scenarios(str(Path(__file__).parent / "features"))
11+
12+
_DISABLED_FLAGS = json.dumps(
13+
{
14+
"flags": {
15+
"disabled-boolean-flag": {
16+
"state": "DISABLED",
17+
"variants": {"on": True, "off": False},
18+
"defaultVariant": "on",
19+
},
20+
"disabled-string-flag": {
21+
"state": "DISABLED",
22+
"variants": {"greeting": "hi", "parting": "bye"},
23+
"defaultVariant": "greeting",
24+
},
25+
"disabled-integer-flag": {
26+
"state": "DISABLED",
27+
"variants": {"one": 1, "ten": 10},
28+
"defaultVariant": "ten",
29+
},
30+
"disabled-float-flag": {
31+
"state": "DISABLED",
32+
"variants": {"tenth": 0.1, "half": 0.5},
33+
"defaultVariant": "half",
34+
},
35+
"disabled-object-flag": {
36+
"state": "DISABLED",
37+
"variants": {
38+
"empty": {},
39+
"template": {
40+
"showImages": True,
41+
"title": "Check out these pics!",
42+
"imagesPerPage": 100,
43+
},
44+
},
45+
"defaultVariant": "template",
46+
},
47+
}
48+
}
49+
)
50+
51+
52+
@pytest.fixture
53+
def evaluator():
54+
core = FlagdCore()
55+
core.set_flags(_DISABLED_FLAGS)
56+
return core

0 commit comments

Comments
 (0)