def test_update_task_with_models(meta: MetadataRepository, project: Project, task: Task, model: Model): task.project = meta.create_project(project) task = meta.create_task(task) assert task is not None id = task.id model.task = task model = meta.create_model(model) task.add_model(model) task = update_object_fields(task, excepted_fields=['id', 'models', 'project_id']) model = update_object_fields(model, excepted_fields=[ 'id', 'wrapper', 'artifact', 'output_meta', 'input_meta', 'requirements', 'transformer', 'task_id' ]) updated_task = meta.update_task(task) assert id == task.id assert updated_task is task assert task == meta.get_task_by_id(task.id) assert len(task.models) == 1 assert model.id in task.models assert model == meta.get_model_by_id(model.id) assert meta.get_model_by_id(model.id).name == 'Test Model2' assert task.has_meta_repo
def test_update_model_source_is_changed(meta: MetadataRepository, project: Project, task: Task, model: Model): task.project = meta.create_project(project) task = meta.create_task(task) assert task is not None model.task_id = task.id saved_model = meta.create_model(model) assert saved_model is not None id = saved_model.id saved_model = update_object_fields(model, excepted_fields=[ 'id', 'wrapper', 'artifact', 'output_meta', 'input_meta', 'requirements', 'transformer', 'task_id' ]) saved_model = meta.update_model(saved_model) assert id == saved_model.id assert model == meta.get_model_by_id(saved_model.id) assert model is saved_model
def test_get_model_by_id(meta: MetadataRepository, project: Project, task: Task, model: Model): task.project = meta.create_project(project) task = meta.create_task(task) assert task is not None model.task_id = task.id model = meta.create_model(model) assert model is not None assert model == meta.get_model_by_id(model.id) assert model.has_meta_repo
def test_create_model_is_reference(meta: MetadataRepository, project: Project, task: Task, model: Model): task.project = meta.create_project(project) task = meta.create_task(task) assert task is not None model.task_id = task.id model = meta.create_model(model) assert model is not None model.name = "KEK" actual_model = meta.get_model_by_id(model.id) assert_objects_equal_except_fields(model, actual_model, excepted_fields=['name']) model.task_id = None actual_model = meta.get_model_by_id(model.id) assert_objects_equal_except_fields(model, actual_model, excepted_fields=['name', 'task_id'])
def test_save_existing_model(meta: MetadataRepository, project: Project, task: Task, model: Model): project = meta.create_project(project) task.project = project task = meta.create_task(task) model.task_id = task.id model = meta.create_model(model) saved_model = meta.save_model(model) assert saved_model.id == model.id assert saved_model.task_id == model.task_id assert model == meta.get_model_by_id(saved_model.id)
def test_save_model_is_reference(meta: MetadataRepository, project: Project, task: Task, model: Model): project = meta.create_project(project) task.project = project task = meta.create_task(task) model.task_id = task.id saved_model = meta.save_model(model) saved_model.name = "KEK" actual_model = meta.get_model_by_id(saved_model.id) assert_objects_equal_except_fields(saved_model, actual_model, excepted_fields=['name'])
def test_save_updated_existing_model(meta: MetadataRepository, project: Project, task: Task, model: Model): project = meta.create_project(project) task.project = project task = meta.create_task(task) model.task_id = task.id model = meta.create_model(model) model = update_object_fields(model, excepted_fields=[ 'id', 'wrapper', 'artifact', 'output_meta', 'input_meta', 'requirements', 'transformer', 'task_id' ]) saved_model = meta.save_model(model) assert saved_model == model assert model == meta.get_model_by_id(saved_model.id)
def test_update_model(meta: MetadataRepository, project: Project, task: Task, model: Model): task.project = meta.create_project(project) task = meta.create_task(task) assert task is not None model.task_id = task.id model = meta.create_model(model) assert model is not None id = model.id model = update_object_fields(model, excepted_fields=[ 'id', 'wrapper', 'artifact', 'requirements', 'wrapper_meta', 'task_id', 'wrapper_obj', 'params' ]) model = meta.update_model(model) assert id == model.id assert model == meta.get_model_by_id(model.id) assert model.has_meta_repo