Repository: oumi-ai/oumi
File: tests/unit/core/synthesis/test_planner.py (Python)

Code before:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import random

import pytest

from oumi.core.configs.params.synthesis_params import (
    AttributeCombination,
    GeneralSynthesisParams,
    PermutableAttribute,
    PermutableAttributeValue,
)
from oumi.core.synthesis.planner import DatasetPlanner


class TestDatasetPlanner:
    @pytest.fixture(autouse=True)
    def setup_random_seed(self):
        """Set up a fixed random seed for deterministic tests."""
        random.seed(42)
        yield
        random.seed()  # Reset the seed after the test

    @pytest.fixture
    def planner(self):
        return DatasetPlanner()

    @pytest.fixture
    def mock_permutable_attributes(self):
        class MockPermutableAttribute1(PermutableAttribute):
            def __init__(self):
                super().__init__(
                    id="attr1",
                    attribute="test1",
                    description="First test attribute",
                    possible_values=[
                        PermutableAttributeValue(
                            id="value1",
                            value="value1",
                            description="First value",
                            sample_rate=0.5,

Review comment (suggestion):
I'd recommend following the test structure we use in our other files. Each test should be a top-level function instead of wrapped in a class. If you're using Cursor for this, tell it to use other test files as a reference.

Code after:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import random

import pytest

from oumi.core.configs.params.synthesis_params import (
    AttributeCombination,
    GeneralSynthesisParams,
    PermutableAttribute,
    PermutableAttributeValue,
)
from oumi.core.synthesis.planner import DatasetPlanner


@pytest.fixture(autouse=True)
def setup_random_seed():
    """Set up a fixed random seed for deterministic tests."""
    random.seed(42)
    yield
    random.seed()  # Reset the seed after the test


@pytest.fixture
def planner():
    return DatasetPlanner()


@pytest.fixture
def mock_permutable_attributes():
    class MockPermutableAttribute1(PermutableAttribute):
        def __init__(self):
            super().__init__(
                id="attr1",
                attribute="test1",
                description="First test attribute",
                possible_values=[
                    PermutableAttributeValue(
                        id="value1",
                        value="value1",
                        description="First value",