recipe.test package

Subpackages

Submodules

recipe.test.test_models module

class recipe.test.test_models.TestRecipeManager(methodName='runTest')

Bases: django.test.testcases.TransactionTestCase

setUp()
test_process_recipe_input()

Tests calling RecipeManager.process_recipe_input()

class recipe.test.test_models.TestRecipePopulateJobs(methodName='runTest')

Bases: django.test.testcases.TransactionTestCase

setUp()
test_successful()

Tests nodes are associated with the recipe successfully?

class recipe.test.test_models.TestRecipeTypeJobLinkManager(methodName='runTest')

Bases: django.test.testcases.TransactionTestCase

setUp()
test_get_job_type_ids()

Tests calling RecipeTypeJobLinkManager.get_job_type_ids()

test_get_recipe_type_ids()

Tests calling RecipeTypeJobLinkManager.get_recipe_type_ids()

class recipe.test.test_models.TestRecipeTypeManagerCreateRecipeTypeV6(methodName='runTest')

Bases: django.test.testcases.TransactionTestCase

setUp()
test_invalid_definition()

Tests calling RecipeTypeManager.create_recipe_type_v6() with an invalid definition

test_successful()

Tests calling RecipeTypeManager.create_recipe_type_v6() successfully.

class recipe.test.test_models.TestRecipeTypeManagerEditRecipeTypeV6(methodName='runTest')

Bases: django.test.testcases.TransactionTestCase

setUp()
test_change_simple()

Tests calling RecipeTypeManager.edit_recipe_type() with only basic attributes

test_change_to_definition(*args, **keywargs)

Tests calling RecipeTypeManager.edit_recipe_type() with a change to the definition

test_change_to_invalid_definition(*args, **keywargs)

Tests calling RecipeTypeManager.edit_recipe_type() with an invalid change to the definition

class recipe.test.test_models.TestRecipeTypeSubLinkManager(methodName='runTest')

Bases: django.test.testcases.TransactionTestCase

setUp()
test_get_recipe_type_ids()

Tests calling RecipeTypeSubLinkManager.get_recipe_type_ids()

test_get_sub_recipe_type_ids()

Tests calling RecipeTypeSubLinkManager.get_sub_recipe_type_ids()

recipe.test.test_views module

class recipe.test.test_views.MockCommandMessageManager
send_messages(commands)
class recipe.test.test_views.TestCreateRecipeTypeViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

Tests related to the post recipe-types base endpoint

api = u'v6'
setUp()
test_create()

Tests creating a new recipe type.

test_create_bad_job_type()

Tests creating a new recipe type with job type that doesn’t exist.

test_create_bad_param()

Tests creating a new recipe type with missing fields.

test_create_existing()
test_create_validation()

Tests creating a new recipe type with the name ‘validation’.

class recipe.test.test_views.TestRecipeDetailsViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

api = u'v6'
setUp()
test_not_found()

Tests calling the recipe details view with an id that does not exist.

test_successful()

Tests getting recipe details

test_superseded()

Tests successfully calling the recipe details view for superseded recipes.

class recipe.test.test_views.TestRecipeInputFilesViewV6(methodName='runTest')

Bases: rest_framework.test.APITestCase

api = u'v6'
setUp()
test_bad_file_name()

Tests unsuccessfully calling the get files by name view

test_file_name_successful()

Tests successfully calling the get files by name view

test_filter_recipe_input()

Tests successfully calling the recipe input files view with recipe_input string filtering

test_successful_file()

Tests successfully calling the recipe input files view

test_time_successful()

Tests successfully calling the get recipe input files view by time

class recipe.test.test_views.TestRecipeReprocessViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

api = u'v6'
setUp()
test_all_jobs(*args, **keywargs)

Tests reprocessing all jobs in an existing recipe

test_bad_job()

Tests reprocessing a non-existant job throws an error

test_bad_json()

Tests reprocessing with bad forced_nodes json input

test_bad_recipe()

Tests reprocessing a non-existant job throws an error

test_bad_revision_num()

Tests reprocessing a recipe with an invalid revision number

test_full_recipe(*args, **keywargs)

Tests reprocessing a full recipe

test_job(*args, **keywargs)

Tests reprocessing one job in an existing recipe

test_superseded()

Tests reprocessing a recipe that is already superseded throws an error.

test_updated_recipe(*args, **keywargs)

Tests reprocessing a recipe that has been updated

class recipe.test.test_views.TestRecipeTypeDetailsViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

Tests related to the recipe-types details endpoint

api = u'v6'
setUp()
test_edit_bad_definition()

Tests attempting to edit a recipe type using an invalid recipe definition

test_edit_definition()

Tests editing the definition of a recipe type

test_edit_definition_and_update(*args, **keywargs)

Tests editing the definition of a recipe type and updating recipes

test_edit_recipeception()

Tests attempting to edit a recipe with sub-recipes of itself

test_edit_simple(*args, **keywargs)

Tests editing only the basic attributes of a recipe type

test_not_found()

Tests calling the recipe type details view with a name that does not exist.

test_successful()

Tests successfully calling the recipe type details view.

class recipe.test.test_views.TestRecipeTypeRevisionDetailsViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

Tests related to the recipe-types details endpoint

api = u'v6'
setUp()
test_not_found()

Tests calling the recipe type revision details view with a revision that does not exist.

test_successful()

Tests successfully calling the recipe type details view.

class recipe.test.test_views.TestRecipeTypeRevisionsViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

Tests related to the recipe-types base endpoint

api = u'v6'
setUp()
test_list_all()

Tests getting a list of recipe types.

class recipe.test.test_views.TestRecipeTypesValidationViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

Tests related to the recipe-types validation endpoint

api = u'v6'
setUp()
test_bad_connection()

Tests validating a new recipe type with a connection to a missing output.

test_bad_job_type()

Tests creating a new recipe type with a job type that doesn’t exist.

test_bad_param()

Tests validating a new recipe type with missing fields.

test_mismatched_warning()

Tests validating a new recipe type.

test_optional_output()

Tests creating a new recipe type with a required input connected to an optional output

test_optional_output_condition()

Tests creating a new recipe type with an optional output hooked up to a condition followed by a required input

test_recipe_not_found_warning()

Tests validating a recipe definition against a recipe-type that doesn’t exist

test_recipeception()

Tests validating a recipe type with a sub-recipe of itself

test_reprocess_warning()

Tests validating an updated recipe type with an unable to reprocess warning.

test_successful_new()

Tests validating a new recipe type.

test_successful_update()

Tests validating an updated recipe type.

class recipe.test.test_views.TestRecipeTypesViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

Tests related to the get recipe-types base endpoint

api = u'v6'
setUp()
test_is_active()

Tests successfully calling the recipetypes view filtered by inactive state.

test_is_system()

Tests successfully calling the recipe types view filtered by system status.

test_keyword()

Tests successfully calling the recipe types view filtered by keyword.

test_list_all()

Tests getting a list of recipe types.

class recipe.test.test_views.TestRecipesPostViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

api = u'v6'
setUp()
test_bad_config()
test_bad_data()
test_inactive()
test_successful_config(*args, **keywargs)
test_successful_v1data(*args, **keywargs)
test_successful_v6data(*args, **keywargs)
class recipe.test.test_views.TestRecipesViewV6(methodName='runTest')

Bases: rest_framework.test.APITransactionTestCase

api = u'v6'
setUp()
test_source_collection()

Tests successfully calling the recipes view filtered by source collection.

test_source_sensor()

Tests successfully calling the recipes view filtered by source sensor.

test_source_sensor_class()

Tests successfully calling the recipes view filtered by source sensor class.

test_source_task()

Tests successfully calling the recipes view filtered by source task.

test_source_time_successful()

Tests successfully calling the get recipes by source time

test_successful_all()

Tests getting recipes

test_successful_batch()

Tests getting recipes by batch id

test_successful_completed()

Tests getting completed recipes

test_successful_id()

Tests getting recipes by id

test_successful_order()

Tests ordering recipes

test_successful_recipe_type_id()

Tests getting recipes by type id

test_successful_recipe_type_name()

Tests getting recipes by type name

test_successful_superseded()

Tests getting superseded recipes

test_time_successful()

Tests successfully calling the get recipes by time

recipe.test.utils module

Defines utility methods for testing jobs and job types

recipe.test.utils.create_conditions(recipe_model, conditions)

Mimics effect of create_conditions_messages for unit testing

recipe.test.utils.create_input_file(recipe=None, input_file=None, recipe_input=None, file_name=u'my_test_file.txt', media_type=u'text/plain', file_size=100, file_path=None, workspace=None, countries=None, is_deleted=False, data_type_tags=[], last_modified=None, source_started=None, source_ended=None)

Creates a Scale file and recipe input file model for unit testing

Returns:The file model
Return type:storage.models.ScaleFile
recipe.test.utils.create_jobs_for_recipe(recipe_model, recipe_jobs)

Mimics effect of create_jobs_messages_for_recipe for unit testing

recipe.test.utils.create_recipe(recipe_type=None, input=None, event=None, is_superseded=False, superseded=None, superseded_recipe=None, config=None, batch=None, save=True)

Creates a recipe for unit testing

Returns:The recipe model
Return type:recipe.models.Recipe
recipe.test.utils.create_recipe_condition(root_recipe=None, recipe=None, batch=None, is_processed=None, is_accepted=None, save=False)

Creates a recipe_node model for unit testing

Parameters:
  • root_recipe (:class:'recipe.models.Recipe') – The root recipe containing the condition
  • recipe (:class:'recipe.models.Recipe') – The recipe containing the condition
  • batch (:class:'batch.models.Batch') – The batch
  • is_processed (bool) – Whether the condition has been processed
  • is_accepted (bool) – Whether the condition has been accepted
Returns:

The recipe_node model

Return type:

recipe.models.RecipeNode

recipe.test.utils.create_recipe_job(recipe=None, job_name=None, job=None)

Creates a job type model for unit testing

Parameters:
  • recipe (:class:'recipe.models.Recipe') – The associated recipe
  • job_name (string) – The associated name for the recipe job
  • job (:class:'job.models.Job') – The associated job
Returns:

The recipe job model

Return type:

recipe.models.RecipeNode

recipe.test.utils.create_recipe_node(recipe=None, node_name=None, condition=None, job=None, sub_recipe=None, save=False, is_original=True)

Creates a recipe_node model for unit testing

Parameters:
  • recipe (:class:'recipe.models.Recipe') – The recipe containing the node
  • node_name (string) – The node name
  • condition (:class:'recipe.models.RecipeCondition') – The condition in the node
  • job (:class:'job.models.Job') – The job in the node
  • sub_recipe (:class:'recipe.models.Recipe') – The recipe in the node
  • save (bool) – Whether to save the model
  • is_original (bool) – Whether the recipe node is original
Returns:

The recipe_node model

Return type:

recipe.models.RecipeNode

recipe.test.utils.create_recipe_type_v6(name=None, version=None, title=None, description=None, definition=None, is_active=None, is_system=None)

Creates a recipe type for unit testing

Returns:The RecipeType model
Return type:recipe.models.RecipeType
recipe.test.utils.create_subrecipes(recipe_model, subrecipes)

Mimics effect of create_subrecipes_messages for unit testing

recipe.test.utils.edit_recipe_type_v6(recipe_type, title=None, description=None, definition=None, auto_update=True, is_active=True)

Updates the definition of a recipe type, including creating a new revision for unit testing

recipe.test.utils.generate_input_data_from_recipe(sub_recipe)

Generates the sub-recipe’s input data from its recipe dependencies and validates and sets the input data on the sub-recipe

Parameters:sub_recipe (recipe.models.Recipe) – The sub-recipe with related recipe_type_rev and recipe__recipe_type_rev models

:raises data.data.exceptions.InvalidData: If the data is invalid

recipe.test.utils.generate_job_input_data_from_recipe(job)

Generates the job’s input data from its recipe dependencies and validates and sets the input data on the job

Parameters:job (job.models.Job) – The job with related job_type_rev and recipe__recipe_type_rev models

:raises data.data.exceptions.InvalidData: If the data is invalid

recipe.test.utils.process_conditions(process_input_condition_ids)

Mimics effect of create_process_condition_messages for unit testing

recipe.test.utils.process_job_inputs(process_input_job_ids)

Mimics effect of create_process_job_input_messages for unit testing

recipe.test.utils.process_recipe_inputs(recipe_ids)

Mimics effect of process_recipe_input messages for unit testing

recipe.test.utils.queue_jobs(queued_jobs, requeue=False, priority=None)

Mimics effect of create_queued_jobs_messages for unit testing

recipe.test.utils.update_jobs_status(job_ids, when=datetime.datetime(2020, 8, 18, 12, 11, 29, 63854, tzinfo=<UTC>), status=u'BLOCKED')

Mimics effect of create_blocked_jobs_messages and create_pending_jobs_messages for unit testing

recipe.test.utils.update_recipe(root_recipe_id)

Mimics effect of update recipe messages for unit testing

recipe.test.utils.update_recipe_metrics(recipe_ids=[], job_ids=None)

Mimics effects of create_update_recipe_metrics_messages methods for unit testing

Module contents