# This test code was written by the `hypothesis.extra.ghostwriter` module
# and is provided under the Creative Commons Zero public domain dedication.

import datetime
import hypothesis
import random
import typing
from hypothesis import given, settings, strategies as st
from typing import Hashable


@given(condition=st.from_type(object))
def test_fuzz_assume(condition: object) -> None:
    hypothesis.assume(condition=condition)


@given(value=st.text())
def test_fuzz_event(value: str) -> None:
    hypothesis.event(value=value)


@given(
    specifier=st.from_type(st.SearchStrategy),
    condition=st.functions(like=lambda *a, **k: None, returns=st.booleans()),
    settings=st.from_type(typing.Optional[hypothesis.settings]),
    random=st.one_of(st.none(), st.randoms()),
    database_key=st.one_of(st.none(), st.binary()),
)
def test_fuzz_find(
    specifier: st.SearchStrategy,
    condition: typing.Callable[[typing.Any], bool],
    settings: typing.Optional[hypothesis.settings],
    random: typing.Optional[random.Random],
    database_key: typing.Optional[bytes],
) -> None:
    hypothesis.find(
        specifier=specifier,
        condition=condition,
        settings=settings,
        random=random,
        database_key=database_key,
    )


@given(value=st.text())
def test_fuzz_note(value: str) -> None:
    hypothesis.note(value=value)


@given(r=st.randoms())
def test_fuzz_register_random(r: random.Random) -> None:
    hypothesis.register_random(r=r)


@given(version=st.text(), blob=st.binary())
def test_fuzz_reproduce_failure(version: str, blob: bytes) -> None:
    hypothesis.reproduce_failure(version=version, blob=blob)


@given(seed=st.from_type(typing.Hashable))
def test_fuzz_seed(seed: typing.Hashable) -> None:
    hypothesis.seed(seed=seed)


@given(
    parent=st.none(),
    max_examples=st.just(not_set),
    derandomize=st.just(not_set),
    database=st.just(not_set),
    verbosity=st.just(not_set),
    phases=st.just(not_set),
    stateful_step_count=st.just(not_set),
    report_multiple_bugs=st.just(not_set),
    suppress_health_check=st.just(not_set),
    deadline=st.just(not_set),
    print_blob=st.just(not_set),
)
def test_fuzz_settings(
    parent: typing.Optional[hypothesis.settings],
    max_examples: int,
    derandomize: bool,
    database,
    verbosity: hypothesis.Verbosity,
    phases,
    stateful_step_count: int,
    report_multiple_bugs: bool,
    suppress_health_check,
    deadline: typing.Union[int, float, datetime.timedelta, None],
    print_blob: bool,
) -> None:
    hypothesis.settings(
        parent=parent,
        max_examples=max_examples,
        derandomize=derandomize,
        database=database,
        verbosity=verbosity,
        phases=phases,
        stateful_step_count=stateful_step_count,
        report_multiple_bugs=report_multiple_bugs,
        suppress_health_check=suppress_health_check,
        deadline=deadline,
        print_blob=print_blob,
    )


@given(name=st.text())
def test_fuzz_settings_get_profile(name: str) -> None:
    hypothesis.settings.get_profile(name=name)


@given(name=st.text())
def test_fuzz_settings_load_profile(name: str) -> None:
    hypothesis.settings.load_profile(name=name)


@given(name=st.text(), parent=st.from_type(typing.Optional[hypothesis.settings]))
def test_fuzz_settings_register_profile(
    name: str, parent: typing.Optional[hypothesis.settings]
) -> None:
    hypothesis.settings.register_profile(name=name, parent=parent)


@given(observation=st.one_of(st.floats(), st.integers()), label=st.text())
def test_fuzz_target(observation: typing.Union[int, float], label: str) -> None:
    hypothesis.target(observation=observation, label=label)
