Skip to content

Commit

Permalink
Correct cleanup after usage e2e tests (#2015)
Browse files Browse the repository at this point in the history
* Correct cleanup after usage e2e tests

Signed-off-by: pyalex <moskalenko.alexey@gmail.com>

* do not override is_enabled directly

Signed-off-by: pyalex <moskalenko.alexey@gmail.com>

* reload modules after test

Signed-off-by: pyalex <moskalenko.alexey@gmail.com>
  • Loading branch information
pyalex authored Nov 10, 2021
1 parent d35fe44 commit 06b1f37
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions sdk/python/tests/integration/e2e/test_usage_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import pytest

from feast import Entity, RepoConfig, ValueType, usage
from feast import Entity, RepoConfig, ValueType
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig


Expand All @@ -31,10 +31,18 @@ def dummy_exporter():
yield event_log


@pytest.mark.integration
def test_usage_on(dummy_exporter):
usage._is_enabled = True
@pytest.fixture(scope="function")
def enabling_toggle():
with patch("feast.usage._is_enabled") as p:
p.__bool__.return_value = True
yield p

# return to initial state
_reload_feast()


@pytest.mark.integration
def test_usage_on(dummy_exporter, enabling_toggle):
_reload_feast()
from feast.feature_store import FeatureStore

Expand Down Expand Up @@ -65,8 +73,8 @@ def test_usage_on(dummy_exporter):


@pytest.mark.integration
def test_usage_off(dummy_exporter):
usage._is_enabled = False
def test_usage_off(dummy_exporter, enabling_toggle):
enabling_toggle.__bool__.return_value = False

_reload_feast()
from feast.feature_store import FeatureStore
Expand Down Expand Up @@ -94,9 +102,7 @@ def test_usage_off(dummy_exporter):


@pytest.mark.integration
def test_exception_usage_on(dummy_exporter):
usage._is_enabled = True

def test_exception_usage_on(dummy_exporter, enabling_toggle):
_reload_feast()
from feast.feature_store import FeatureStore

Expand All @@ -111,8 +117,8 @@ def test_exception_usage_on(dummy_exporter):


@pytest.mark.integration
def test_exception_usage_off(dummy_exporter):
usage._is_enabled = False
def test_exception_usage_off(dummy_exporter, enabling_toggle):
enabling_toggle.__bool__.return_value = False

_reload_feast()
from feast.feature_store import FeatureStore
Expand Down

0 comments on commit 06b1f37

Please # to comment.