Esempio n. 1
0
def test_project_tree_unknown_element():
    project_tree = ManageProjectElements()
    project_tree.add_element(81818, 0, {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30})
    project_tree.add_element(81819, 81818, {'timeworked': 30, 'timeestimated': 50, 'timeleft': 20})

    response = project_tree.project_tree(3333)
    assert response == []
Esempio n. 2
0
def test_add_element_integers():
    project_tree = ManageProjectElements()
    with pytest.raises(ValueError) as value_error:
        project_tree.add_element('81818', 0, {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30})
    assert 'value error: Expecting integers!' in str(value_error)

    with pytest.raises(ValueError) as value_error:
        project_tree.add_element(81819, '81819', {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30})
    assert 'value error: Expecting integers!' in str(value_error)
Esempio n. 3
0
def test_add_element():
    project_tree = ManageProjectElements()
    project_tree.add_element(81818, 0, {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30})

    assert project_tree.elements.list[0][0] == 81818
    assert project_tree.elements.list[0][1].element == 81818
    assert project_tree.elements.list[0][1].element_time_worked == 10
    assert project_tree.elements.list[0][1].element_time_estimated == 20
    assert project_tree.elements.list[0][1].element_time_left == 30
Esempio n. 4
0
def test_add_element_parent():
    project_tree = ManageProjectElements()
    project_tree.add_element(81818, 0, {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30})
    project_tree.add_element(81819, 81818, {'timeworked': 30, 'timeestimated': 50, 'timeleft': 20})

    assert project_tree.elements.list[0][0] == 81818
    assert project_tree.elements.list[1][0] == 81819
    assert project_tree.elements.list[0][1].children[0].element == 81819
    assert project_tree.elements.list[0][1].project_time_worked == 40
    assert project_tree.elements.list[0][1].project_time_estimated == 70
    assert project_tree.elements.list[0][1].project_time_left == 50
Esempio n. 5
0
def test_project_tree():
    project_tree = ManageProjectElements()
    project_tree.add_element(81818, 0, {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30})
    project_tree.add_element(81819, 81818, {'timeworked': 30, 'timeestimated': 50, 'timeleft': 20})

    response = project_tree.project_tree(81818)
    assert response == [
        81818,
        {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30},
        40,
        70,
        50,
        [
            [
                81819,
                {'timeworked': 30, 'timeestimated': 50, 'timeleft': 20},
                30,
                50,
                20,
                []
            ]
        ]
    ]
Esempio n. 6
0
def test_add_element_unknown_parent():
    project_tree = ManageProjectElements()
    with pytest.raises(ValueError) as value_error:
        project_tree.add_element(81819, 81819, {'timeworked': 10, 'timeestimated': 20, 'timeleft': 30})
    assert 'Parent not inserted yet!' in str(value_error)