コード例 #1
0
ファイル: test_models.py プロジェクト: zhongerqiandan/optuna
    def test_cascade_delete_on_trial(session: Session) -> None:

        trial = TestTrialIntermediateValueModel._create_model(session)
        trial.intermediate_values.append(
            TrialIntermediateValueModel(trial_id=1, step=1, intermediate_value=20)
        )
        session.commit()

        assert 2 == len(TrialIntermediateValueModel.where_trial_id(trial.trial_id, session))

        session.delete(trial)
        session.commit()

        assert 0 == len(TrialIntermediateValueModel.where_trial_id(trial.trial_id, session))
コード例 #2
0
ファイル: test_models.py プロジェクト: stjordanis/optuna
    def test_where_trial_id(session: Session) -> None:

        trial = TestTrialIntermediateValueModel._create_model(session)
        trial_intermediate_values = TrialIntermediateValueModel.where_trial_id(
            trial.trial_id, session)
        assert 1 == len(trial_intermediate_values)
        assert 0 == trial_intermediate_values[0].step
        assert 10 == trial_intermediate_values[0].intermediate_value