Skip to content

Commit dfdce36

Browse files
authored
Merge branch 'main' into feature/refactor_and_switch_to_single_client
2 parents 5d34cd8 + b69e81a commit dfdce36

File tree

7 files changed

+89
-8
lines changed

7 files changed

+89
-8
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
- if: matrix.python-version == '3.11'
4848
name: Upload coverage to Codecov
49-
uses: codecov/codecov-action@v5.1.2
49+
uses: codecov/codecov-action@v5.2.0
5050
with:
5151
flags: unittests # optional
5252
name: coverage # optional

.github/workflows/release.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ jobs:
3737
# IMPORTANT: this permission is mandatory for trusted publishing to pypi
3838
id-token: write
3939
needs: release-please
40-
if: ${{ needs.release-please.outputs.release_created }}
41-
container:
42-
image: "python:3.13"
40+
if: ${{ fromJSON(needs.release-please.outputs.release_created || false) }}
4341

4442
steps:
45-
- uses: actions/checkout@v4
43+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
44+
45+
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
46+
with:
47+
python-version: '3.13'
4648

4749
- name: Upgrade pip
4850
run: pip install --upgrade pip
@@ -54,5 +56,4 @@ jobs:
5456
run: hatch build
5557

5658
- name: Publish a Python distribution to PyPI
57-
# pinning till fixed https://github.com/pypa/gh-action-pypi-publish/issues/300
58-
uses: pypa/gh-action-pypi-publish@release/v1.11
59+
uses: pypa/gh-action-pypi-publish@release/v1

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "test-harness"]
22
path = test-harness
33
url = https://github.com/open-feature/test-harness.git
4+
[submodule "spec"]
5+
path = spec
6+
url = https://github.com/open-feature/spec.git

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
default_stages: [commit]
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.9.1
4+
rev: v0.9.2
55
hooks:
66
- id: ruff
77
args: [--fix]

tests/features/data.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,16 @@ def context_func(flag: InMemoryFlag, evaluation_context: EvaluationContext):
6969
variants={"one": "uno", "two": "dos"},
7070
default_variant="one",
7171
),
72+
"metadata-flag": InMemoryFlag(
73+
state=InMemoryFlag.State.ENABLED,
74+
default_variant="on",
75+
variants={"on": True, "off": False},
76+
context_evaluator=None,
77+
flag_metadata={
78+
"string": "1.0.2",
79+
"integer": 2,
80+
"float": 0.1,
81+
"boolean": True,
82+
},
83+
),
7284
}

tests/features/steps/flag_steps.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from behave import given, when
2+
3+
4+
@given('a {flag_type}-flag with key "{flag_key}" and a default value "{default_value}"')
5+
def step_impl_flag(context, flag_type: str, flag_key, default_value):
6+
context.flag = (flag_type, flag_key, default_value)
7+
8+
9+
@when("the flag was evaluated with details")
10+
def step_impl_evaluation(context):
11+
client = context.client
12+
flag_type, key, default_value = context.flag
13+
if flag_type.lower() == "string":
14+
context.evaluation = client.get_string_details(key, default_value)
15+
elif flag_type.lower() == "boolean":
16+
context.evaluation = client.get_boolean_details(key, default_value)
17+
elif flag_type.lower() == "object":
18+
context.evaluation = client.get_object_details(key, default_value)
19+
elif flag_type.lower() == "float":
20+
context.evaluation = client.get_float_details(key, default_value)
21+
elif flag_type.lower() == "integer":
22+
context.evaluation = client.get_integer_details(key, default_value)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from behave import given, then
2+
3+
from openfeature.api import get_client, set_provider
4+
from openfeature.provider.in_memory_provider import InMemoryProvider
5+
from tests.features.data import IN_MEMORY_FLAGS
6+
7+
8+
@given("a stable provider")
9+
def step_impl_stable_provider(context):
10+
set_provider(InMemoryProvider(IN_MEMORY_FLAGS))
11+
context.client = get_client()
12+
13+
14+
@then('the resolved metadata value "{key}" should be "{value}"')
15+
def step_impl_check_metadata(context, key, value):
16+
assert context.evaluation.flag_metadata[key] == value
17+
18+
19+
@then("the resolved metadata is empty")
20+
def step_impl_empty_metadata(context):
21+
assert not context.evaluation.flag_metadata
22+
23+
24+
@then("the resolved metadata should contain")
25+
def step_impl_metadata_contains(context):
26+
for row in context.table:
27+
key, metadata_type, value = row
28+
29+
assert context.evaluation.flag_metadata[
30+
key
31+
] == convert_value_from_metadata_type(value, metadata_type)
32+
33+
34+
def convert_value_from_metadata_type(value, metadata_type):
35+
if value == "None":
36+
return None
37+
if metadata_type.lower() == "boolean":
38+
return bool(value)
39+
elif metadata_type.lower() == "integer":
40+
return int(value)
41+
elif metadata_type.lower() == "float":
42+
return float(value)
43+
return value

0 commit comments

Comments
 (0)