diff --git a/python-sdk/pytest.ini b/python-sdk/pytest.ini index 04bef679..f0aaa372 100644 --- a/python-sdk/pytest.ini +++ b/python-sdk/pytest.ini @@ -1,3 +1,3 @@ [pytest] markers = - rust_only: mark a test as only passing on Rust-based SDK. + rust_only: mark a test as only passing on Python-on-Rust SDK. diff --git a/python-sdk/python/tests/test_assignment_logger.py b/python-sdk/python/tests/test_assignment_logger.py index b82b0833..eb4bcd0d 100644 --- a/python-sdk/python/tests/test_assignment_logger.py +++ b/python-sdk/python/tests/test_assignment_logger.py @@ -1,6 +1,6 @@ from typing import Dict -from eppo_client import AssignmentLogger +from eppo_client.assignment_logger import AssignmentLogger def test_can_inherit_assignment_logger(): diff --git a/python-sdk/python/tests/test_config.py b/python-sdk/python/tests/test_config.py index 4afc3bcb..4ba70985 100644 --- a/python-sdk/python/tests/test_config.py +++ b/python-sdk/python/tests/test_config.py @@ -1,29 +1,37 @@ import pytest -from eppo_client import Config, AssignmentLogger +from eppo_client.config import Config +from eppo_client.assignment_logger import AssignmentLogger class TestConfig: def test_can_create_with_api_key_and_assignment_logger(self): Config(api_key="test-key", assignment_logger=AssignmentLogger()) + @pytest.mark.rust_only def test_requires_non_empty_key(self): with pytest.raises(ValueError): Config(api_key="", assignment_logger=AssignmentLogger()) def test_requires_api_key(self): - with pytest.raises(TypeError): + # Python SDK raises Pydantic's ValidationError. + # Python-on-rust raises TypeError. + with pytest.raises(Exception): Config(assignment_logger=AssignmentLogger()) def test_requires_assignment_logger(self): - with pytest.raises(TypeError): + # Python SDK raises Pydantic's ValidationError. + # Python-on-rust raises TypeError. + with pytest.raises(Exception): Config(api_key="test-key") def test_assignment_logger_must_be_a_subclass_of_logger(self): class MyLogger: pass - with pytest.raises(TypeError): + # Python SDK raises Pydantic's ValidationError. + # Python-on-rust raises TypeError. + with pytest.raises(Exception): Config(api_key="test-key", assignment_logger=MyLogger()) def test_assignment_accepts_a_subclass_of_logger(self): @@ -32,7 +40,15 @@ class MyLogger(AssignmentLogger): Config(api_key="test-key", assignment_logger=MyLogger()) + # This one is failing on native python sdk as we don't have + # `validate_assignment` enabled. + @pytest.mark.rust_only def test_cant_reset_assignment_logger(self): config = Config(api_key="test-key", assignment_logger=AssignmentLogger()) with pytest.raises(TypeError): config.assignment_logger = None + assert config.assignment_logger is not None + + def test_can_set_assignment_logger_to_another_logger(self): + config = Config(api_key="test-key", assignment_logger=AssignmentLogger()) + config.assignment_logger = AssignmentLogger() diff --git a/python-sdk/python/tests/test_sdk_test_data_eval_assignment.py b/python-sdk/python/tests/test_sdk_test_data_eval_assignment.py index a723752e..ea10fc08 100644 --- a/python-sdk/python/tests/test_sdk_test_data_eval_assignment.py +++ b/python-sdk/python/tests/test_sdk_test_data_eval_assignment.py @@ -4,8 +4,11 @@ from time import sleep import eppo_client +from eppo_client.assignment_logger import AssignmentLogger -TEST_DIR = "../sdk-test-data/ufc/tests" +TEST_DIR = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "../../../sdk-test-data/ufc/tests" +) test_data = [] for file_name in os.listdir(TEST_DIR): with open("{}/{}".format(TEST_DIR, file_name)) as test_case_json: @@ -19,10 +22,10 @@ @pytest.fixture(scope="session", autouse=True) def init_fixture(): eppo_client.init( - eppo_client.Config( + eppo_client.config.Config( base_url=MOCK_BASE_URL + "ufc/api", api_key="dummy", - assignment_logger=eppo_client.AssignmentLogger(), + assignment_logger=AssignmentLogger(), ) ) sleep(0.1) # wait for initialization