Exemple #1
0
def test_find_or_create_raise_error_project_exist(project_collection):
    # test when project exists and raise_error flag is on
    collection = project_collection()
    old_project_count = len(list(collection.list()))
    result = find_or_create_project(collection, "project 3", raise_error=True)
    new_project_count = len(list(collection.list()))
    assert result.name == "project 3"
    assert new_project_count == old_project_count
Exemple #2
0
def test_find_or_create_project_exist_no_search(project_collection):
    # test when project exists
    collection = project_collection(False)
    old_project_count = len(list(collection.list()))
    result = find_or_create_project(collection, "project 2")
    new_project_count = len(list(collection.list()))
    assert result.name == "project 2"
    assert new_project_count == old_project_count
Exemple #3
0
def test_find_or_create_project_no_exist(project_collection):
    # test when project doesn't exist
    collection = project_collection()
    old_project_count = len(list(collection.list()))
    result = find_or_create_project(collection, absent_name)
    new_project_count = len(list(collection.list()))
    assert result.name == absent_name
    assert new_project_count == old_project_count + 1
Exemple #4
0
def test_find_or_create_raise_error_project_exist_multiple(project_collection):
    # test when project exists multiple times and raise_error flag is on
    with pytest.raises(ValueError):
        find_or_create_project(project_collection(),
                               duplicate_name,
                               raise_error=True)
Exemple #5
0
def test_find_or_create_raise_error_project_no_exist(project_collection):
    # test when project doesn't exist and raise_error flag is on
    with pytest.raises(ValueError):
        find_or_create_project(project_collection(),
                               absent_name,
                               raise_error=True)
Exemple #6
0
def test_find_or_create_project_exist_multiple(project_collection):
    # test when project exists multiple times
    with pytest.raises(ValueError):
        find_or_create_project(project_collection(), duplicate_name)