Beispiel #1
0
def create_recipe(recipe_type=None, data=None, event=None, is_superseded=False, superseded=None):
    """Creates a recipe for unit testing

    :returns: The recipe model
    :rtype: :class:`recipe.models.Recipe`
    """

    if not recipe_type:
        recipe_type = create_recipe_type()
    if not data:
        data = {}
    if not event:
        event = trigger_test_utils.create_trigger_event()
    if is_superseded and not superseded:
        superseded = timezone.now()

    recipe = Recipe()
    recipe.recipe_type = recipe_type
    recipe.recipe_type_rev = RecipeTypeRevision.objects.get_revision(recipe_type.id, recipe_type.revision_num)
    recipe.event = event
    recipe.data = data
    recipe.is_superseded = is_superseded
    recipe.superseded = superseded
    recipe.save()

    return recipe
Beispiel #2
0
def create_recipe(recipe_type=None, data=None, event=None):
    '''Creates a job type model for unit testing

    :param recipe_type: The associated recipe type
    :type recipe_type: :class:'recipe.models.RecipeType'
    :param data: The associated data for the recipe
    :type data: dict
    :param event: The associated event
    :type event: :class:'trigger.models.TriggerEvent'
    :returns: The recipe model
    :rtype: :class:`recipe.models.Recipe`
    '''

    if not data:
        data = {}

    if not recipe_type:
        recipe_type = create_recipe_type()

    if not event:
        event = trigger_test_utils.create_trigger_event()

    recipe = Recipe()
    recipe.recipe_type = recipe_type
    recipe.recipe_type_rev = RecipeTypeRevision.objects.get_revision(recipe_type.id, recipe_type.revision_num)
    recipe.event = event
    recipe.data = data
    recipe.save()

    return recipe
Beispiel #3
0
def create_recipe(recipe_type=None, data=None, event=None):
    '''Creates a job type model for unit testing

    :param recipe_type: The associated recipe type
    :type recipe_type: :class:'recipe.models.RecipeType'
    :param data: The associated data for the recipe
    :type data: dict
    :param event: The associated event
    :type event: :class:'trigger.models.TriggerEvent'
    :returns: The recipe model
    :rtype: :class:`recipe.models.Recipe`
    '''

    if not data:
        data = {}

    if not recipe_type:
        recipe_type = create_recipe_type()

    if not event:
        event = trigger_test_utils.create_trigger_event()

    recipe = Recipe()
    recipe.recipe_type = recipe_type
    recipe.recipe_type_rev = RecipeTypeRevision.objects.get_revision(
        recipe_type.id, recipe_type.revision_num)
    recipe.event = event
    recipe.data = data
    recipe.save()

    return recipe
Beispiel #4
0
def create_recipe(recipe_type=None, data=None, event=None, is_superseded=False, superseded=None):
    """Creates a recipe for unit testing

    :returns: The recipe model
    :rtype: :class:`recipe.models.Recipe`
    """

    if not recipe_type:
        recipe_type = create_recipe_type()
    if not data:
        data = {}
    if not event:
        event = trigger_test_utils.create_trigger_event()
    if is_superseded and not superseded:
        superseded = timezone.now()

    recipe = Recipe()
    recipe.recipe_type = recipe_type
    recipe.recipe_type_rev = RecipeTypeRevision.objects.get_revision(recipe_type.id, recipe_type.revision_num)
    recipe.event = event
    recipe.data = data
    recipe.is_superseded = is_superseded
    recipe.superseded = superseded
    recipe.save()

    return recipe