Esempio n. 1
0
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)
Esempio n. 2
0
def test_task__add_models(task_b: Task, model_factory,
                          meta: MetadataRepository):
    models = [model_factory() for _ in range(5)]
    assert len(task_b.models) == 0
    task_b.add_models(models)
    assert len(task_b.models) == 5

    for m in models:
        model_id = m.id
        assert model_id is not None
        assert m == meta.get_model_by_id(model_id)
        assert m == task_b.models[model_id]
        assert m == task_b.models(m.name)