def test_findTask(): project = pert.Project() with pytest.raises(AttributeError) as exception: project.findTask("asdf") # Check that the relevant key appears in the exception message assert "asdf" in str(exception.value)
def test_addDuplicate(): project = pert.Project() project.addTask(pert.Task("task1")) with pytest.raises(AttributeError) as exception: project.addTask(pert.Task("task1", title="different title")) assert "already exists" in str(exception.value)
def test_addTask(): project = pert.Project() project.addTask(pert.Task("task1")) project.addTask(pert.Task("task2")) project.addTask(pert.Task("task3")) assert project.findTask("task1") assert project.findTask("task2") assert project.findTask("task3")
def test_dependencies(): project = pert.Project() task1 = pert.Task("task1") task2 = pert.Task("task2") task3 = pert.Task("task3") project.addTask(task1) project.addTask(task2) project.addTask(task3, depends_on=[task1, task2]) assert project.findDependencies(task1) == [] assert project.findDependencies(task2) == [] assert project.findDependencies(task3) == [task1, task2]
def test_save(output_file): project = pert.Project() task1 = pert.Task("My least favourite task") task2 = pert.Task("Create a new test for the current suite") task3 = pert.Task( "Transform fossil from lab into a live and dangerous dinosaur") project.addTask(task1) project.addTask(task2, depends_on=[task1]) project.addTask(task3, depends_on=[task1, task2]) pert_chart = pert.Chart(project, arrangement=pert.Arrangement.Random) pert_chart.save(output_file, format="svg") assert os.path.isfile(output_file)
def test_layout_dimensions(): project = pert.Project() project.addTask(pert.Task("My least favourite task")) box1 = pert.Box(pert.Task("task1"), width=10, height=20, x=12, y=100) assert (10 + 12, 100 + 20) == pert.find_layout_dimensions([box1])