import typing


def _setup(db_state) -> typing.Tuple:
    """Create some test data from a given db state"""
    organisation_model = db_state.apps.get_model("organisations", "Organisation")
    project_model = db_state.apps.get_model("projects", "Project")
    feature_model = db_state.apps.get_model("features", "Feature")
    environment_model = db_state.apps.get_model("environments", "Environment")
    feature_state_model = db_state.apps.get_model("features", "FeatureState")

    organisation = organisation_model.objects.create(name="Test org")
    project = project_model.objects.create(
        name="Test project", organisation=organisation
    )
    environment = environment_model.objects.create(
        name="Test Environment", project=project
    )
    feature = feature_model.objects.create(name="test_feature", project=project)
    feature_state = feature_state_model.objects.create(
        feature=feature, environment=environment
    )

    return organisation, project, environment, feature, feature_state