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_task__delete_model(task_b: Task, model): task_b.add_model(model) assert model.id is not None assert model.task_id is not None task_b.delete_model(model) assert len(task_b.models) == 0 assert model.id is None assert model.task_id is None
def test_task__add_model__new(set_task_id, meta: MetadataRepository, task_b: Task, model_factory): assert len(task_b.models) == 0 model: Model = model_factory() if set_task_id: model.task = task_b task_b.add_model(model) assert len(task_b.models) == 1 model_id = model.id assert model_id is not None assert model == meta.get_model_by_id(model_id) assert model == task_b.models[model_id] assert model == task_b.models(model.name)