Skip to content

Commit

Permalink
chore: Change pytest fixtures to be function-scoped instead of sessio…
Browse files Browse the repository at this point in the history
…n-scoped (#2899)

* Test to trigger registry conflicts

Signed-off-by: Felix Wang <[email protected]>

* Switch environment and associated fixtures to being function scoped

Signed-off-by: Felix Wang <[email protected]>

* Format

Signed-off-by: Felix Wang <[email protected]>

* Switch type tests to function-scoped fixtures

Signed-off-by: Felix Wang <[email protected]>

* Format

Signed-off-by: Felix Wang <[email protected]>
  • Loading branch information
felixwang9817 authored and adchia committed Jul 14, 2022
1 parent f5196cf commit 24eec39
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
8 changes: 4 additions & 4 deletions sdk/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def start_test_local_server(repo_path: str, port: int):
fs.serve("localhost", port, no_access_log=True)


@pytest.fixture(scope="session")
@pytest.fixture
def environment(request, worker_id):
e = construct_test_environment(
request.param, worker_id=worker_id, fixture_request=request
Expand Down Expand Up @@ -293,7 +293,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc):
)


@pytest.fixture(scope="session")
@pytest.fixture
def feature_server_endpoint(environment):
if (
not environment.python_feature_server
Expand Down Expand Up @@ -344,12 +344,12 @@ def _free_port():
return sock.getsockname()[1]


@pytest.fixture(scope="session")
@pytest.fixture
def universal_data_sources(environment) -> TestData:
return construct_universal_test_data(environment)


@pytest.fixture(scope="session")
@pytest.fixture
def e2e_data_sources(environment: Environment):
df = create_dataset()
data_source = environment.data_source_creator.create_data_source(
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/tests/integration/e2e/test_go_feature_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)


@pytest.fixture(scope="session")
@pytest.fixture
def initialized_registry(environment, universal_data_sources):
fs = environment.feature_store

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class TypeTestConfig:


@pytest.fixture(
params=OFFLINE_TYPE_TEST_CONFIGS,
scope="session",
ids=[str(c) for c in OFFLINE_TYPE_TEST_CONFIGS],
params=OFFLINE_TYPE_TEST_CONFIGS, ids=[str(c) for c in OFFLINE_TYPE_TEST_CONFIGS],
)
def offline_types_test_fixtures(request, environment):
config: TypeTestConfig = request.param
Expand All @@ -80,9 +78,7 @@ def offline_types_test_fixtures(request, environment):


@pytest.fixture(
params=ONLINE_TYPE_TEST_CONFIGS,
scope="session",
ids=[str(c) for c in ONLINE_TYPE_TEST_CONFIGS],
params=ONLINE_TYPE_TEST_CONFIGS, ids=[str(c) for c in ONLINE_TYPE_TEST_CONFIGS],
)
def online_types_test_fixtures(request, environment):
return get_fixtures(request, environment)
Expand Down
23 changes: 23 additions & 0 deletions sdk/python/tests/unit/test_registry_conflict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest

from feast.entity import Entity


@pytest.mark.integration
def test_apply_first_entity(environment):
entity = Entity(name="first")
fs = environment.feature_store
fs.apply([entity])

entities = fs.list_entities()
assert len(entities) == 1


@pytest.mark.integration
def test_apply_second_entity(environment):
entity = Entity(name="second")
fs = environment.feature_store
fs.apply([entity])

entities = fs.list_entities()
assert len(entities) == 1

0 comments on commit 24eec39

Please sign in to comment.