Пример #1
0
def test_delete_study_command(options):
    # type: (List[str]) -> None

    with StorageConfigSupplier(TEST_CONFIG_TEMPLATE) as (storage_url,
                                                         config_path):
        storage = RDBStorage(storage_url)
        study_name = "delete-study-test"

        # Create study.
        command = [
            'optuna', 'create-study', '--storage', storage_url, '--study-name',
            study_name
        ]
        subprocess.check_call(command)
        assert study_name in {
            s.study_name: s
            for s in storage.get_all_study_summaries()
        }

        # Delete study.
        command = [
            'optuna', 'delete-study', '--storage', storage_url, '--study-name',
            study_name
        ]
        subprocess.check_call(command)
        assert study_name not in {
            s.study_name: s
            for s in storage.get_all_study_summaries()
        }
def test_delete_study_after_create_multiple_studies():
    # type: () -> None

    storage = RDBStorage('sqlite:///:memory:')
    study_id1 = storage.create_new_study()
    study_id2 = storage.create_new_study()
    study_id3 = storage.create_new_study()

    storage.delete_study(study_id2)

    studies = {s.study_id: s for s in storage.get_all_study_summaries()}
    assert study_id1 in studies
    assert study_id2 not in studies
    assert study_id3 in studies