Skip to content

Commit

Permalink
fix: float/int type casting
Browse files Browse the repository at this point in the history
Signed-off-by: Cole Bailey <[email protected]>
  • Loading branch information
colebaileygit committed Apr 27, 2024
1 parent 1899571 commit 2bfffe6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,21 @@ def resolve_float_details(
default_value: float,
evaluation_context: typing.Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[float]:
return self._resolve(key, default_value, evaluation_context)
result = self._resolve(key, default_value, evaluation_context)
if not isinstance(result.value, float):
result.value = float(result.value)
return result

def resolve_integer_details(
self,
key: str,
default_value: int,
evaluation_context: typing.Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[int]:
return self._resolve(key, default_value, evaluation_context)
result = self._resolve(key, default_value, evaluation_context)
if not isinstance(result.value, int):
result.value = int(result.value)
return result

def resolve_object_details(
self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import logging
import time

import pytest
from pytest_bdd import parsers, scenario, then, when
from pytest_bdd import parsers, scenarios, then, when

from openfeature.client import OpenFeatureClient, ProviderEvent

GHERKIN_FOLDER = "../../../../test-harness/gherkin/"


@scenario(f"{GHERKIN_FOLDER}flagd.feature", "Provider ready event")
def test_ready_event(caplog):
"""Provider ready event"""
caplog.set_level(logging.DEBUG)


@scenario(f"{GHERKIN_FOLDER}flagd.feature", "Flag change event")
def test_change_event():
"""Flag change event"""
scenarios(f"{GHERKIN_FOLDER}flagd-json-evaluator.feature")
scenarios(f"{GHERKIN_FOLDER}flagd.feature")


@pytest.fixture
Expand Down Expand Up @@ -71,14 +62,6 @@ def modify_flag(key):
pass


# def modify_flag(flag_file, key):
# time.sleep(0.1) # guard against race condition
# with open("test-harness/flags/changing-flag-foo.json") as src_file:
# contents = src_file.read()
# with open(flag_file, "w") as f:
# f.write(contents)


@then(parsers.cfparse('the event details must indicate "{key}" was altered'))
def assert_flag_changed(handles, key):
handle = None
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 2bfffe6

Please sign in to comment.