Example #1
0
def test_group_random1():
    """Testing that the group_random() function creates the
        appropriate number of groups with the appropriate number"""
    lst = [
        "Austin",
        "Dan",
        "Angie",
        "Cullen",
        "Chase",
        "Vinny",
        "Nick",
        "Jeff",
        "James",
        "Kelly",
        "Nikki",
        "Robert",
    ]
    lst2 = ["Dan", "Angie", "Austin", "Izaak", "Nick", "Jeff"]
    group_size = 3
    group_size2 = 2
    num_group = 2
    num_group2 = 3
    actual_output = group_creation.group_random_group_size(lst, group_size)
    actual_output2 = group_creation.group_random_group_size(lst2, group_size2)
    actual_output3 = group_creation.group_random_num_group(lst, num_group)
    actual_output4 = group_creation.group_random_num_group(lst2, num_group2)

    assert len(actual_output) == 4
    assert len(actual_output[0]) == 3
    assert len(actual_output2) == 3
    assert len(actual_output2[0]) == 2
    assert len(actual_output3) == 2
    assert len(actual_output3[0]) == 6
    assert len(actual_output4) == 3
    assert len(actual_output4[0]) == 2
Example #2
0
def hypothesis_test_group_random1(group_size):
    """this hypothesis test can generate the group numbers and test if it pass
        the requirements"""
    lst = [
        "Austin",
        "Dan",
        "Angie",
        "Cullen",
        "Chase",
        "Vinny",
        "Nick",
        "Jeff",
        "James",
        "Kelly",
        "Nikki",
        "Robert",
    ]
    lst2 = ["Dan", "Angie", "Austin", "Izaak", "Nick", "Jeff"]
    size_count = group_size
    actual_output = group_creation.group_random_group_size(lst, group_size)
    actual_output2 = group_creation.group_random_group_size(lst2, group_size)

    assert len(actual_output) == 12 // size_count
    assert len(actual_output[0]) == size_count
    assert len(actual_output2) == 6 // size_count
    assert len(actual_output2[0]) == size_count
Example #3
0
def test_group_random2(grpsize):
    """This hypothesis test will test the group_random_group_size method"""
    responses = [
        ["Nick", True, False, True, False],
        ["Marvin", False, False, True, True],
        ["Evin", True, True, True, False],
        ["Nikki", True, True, False, False],
        ["Nick", True, False, True, False],
        ["Dan", False, True, False, True],
    ]
    returned_groups = group_creation.group_random_group_size(
        responses, grpsize)
    size_count = grpsize
    assert len(returned_groups[0]) == size_count
Example #4
0
def test_hypothesis_group_random(grpsize):
    """Testing the random type of grouping with everyone in an assigned group with hypothesis"""
    responses = [
        ["Nick", True, False, True, False],
        ["Marvin", False, False, True, True],
        ["Evin", True, True, True, False],
        ["Nikki", True, True, False, False],
        ["Dan", False, True, False, True],
        ["Michael", True, True, False, False],
    ]
    num_group = len(responses) // grpsize
    returned_groups = group_creation.group_random_group_size(
        responses, grpsize)
    returned_groups1 = group_creation.group_random_num_group(
        responses, num_group)
    assert len(returned_groups) == num_group
    assert len(returned_groups1[0]) == grpsize
Example #5
0
def test_group_random():
    """Testing the random type of grouping with everyone in an assigned group"""
    responses = [
        ["Nick", True, False, True, False],
        ["Marvin", False, False, True, True],
        ["Evin", True, True, True, False],
        ["Nikki", True, True, False, False],
        ["Dan", False, True, False, True],
        ["Michael", True, True, False, False],
    ]
    grpsize = 2
    num_group = 3
    returned_groups = group_creation.group_random_group_size(
        responses, grpsize)
    returned_groups1 = group_creation.group_random_num_group(
        responses, num_group)
    assert len(returned_groups) == 3
    assert len(returned_groups1[0]) == 2
Example #6
0
def test_group_random_extra():
    """Testing the random type of grouping with a group of extra people not assigned
     to their own group"""
    responses = [
        ["Nick", True, False, True, False],
        ["Marvin", False, False, True, True],
        ["Evin", True, True, True, False],
        ["Nikki", True, True, False, False],
        ["Dan", False, True, False, True],
    ]
    grpsize = 2
    num_group = 2
    returned_groups = group_creation.group_random_group_size(
        responses, grpsize)
    returned_groups1 = group_creation.group_random_num_group(
        responses, num_group)
    assert len(returned_groups) == 2
    assert grpsize == 2
    assert len(returned_groups1) == 2
    assert num_group == 2
Example #7
0
def test_hypothesis_random(grpsize):
    """Testing the random grouping function to assure proper output"""
    lst = [
        ["Dan", True, True, True],
        ["Jesse", True, True, True],
        ["Austin", True, True, True],
        ["Nick", False, False, False],
        ["Nikki", False, False, False],
        ["Maria", False, False, False],
        ["Jeff", False, False, False],
        ["Simon", False, False, False],
        ["Jon", False, False, False],
        ["Angie", False, False, False],
        ["Izaak", False, False, False],
        ["Jacob", False, False, False],
    ]
    num_group = len(lst) // grpsize
    actual_output = group_creation.group_random_group_size(lst, grpsize)
    actual_output1 = group_creation.group_random_num_group(lst, num_group)
    assert len(actual_output) == num_group
    assert len(actual_output[0]) == grpsize
    assert len(actual_output1) == num_group
    assert len(actual_output1[0]) == grpsize
Example #8
0
def test_group_random_conflict_grpsize():
    """
    Test that groups are still created randomly, even when given
    conflict tuples as input. Note that there is no guarantee that
    a conflict will be avoided, but rather that it is more likely that
    the conflict will be avoided than it won't. See docstring comment for
    test_group_random_conflict_numgrp for details of this testing method,
    as the process is similar.
    """
    responses = [
        ["Nick", True, False, True, False],
        ["Marvin", False, False, True, True],
        ["Evin", True, True, True, False],
        ["Nikki", True, True, False, False],
        ["Dan", False, True, False, True],
        ["Michael", True, True, False, False],
    ]
    group_size = 2
    # A conflict is added.
    conflict = ("Nick", "Marvin", 5)
    results = []
    # Run 1000 tests for significance
    for _x in range(0, 1000):
        returned_groups = group_creation.group_random_group_size(
            responses, group_size)
        for grp in returned_groups:
            # if both members of the conflict relation are in a group, avoidance failed
            if (conflict[0] in grp) and (conflict[1] in grp):
                # 1 denotes conflict avoidance failure
                results.append(1)
            else:
                # 0 denotes conflict avoidance failure
                results.append(0)
    # calculate the average of the results
    results_avg = sum(results) / len(results)
    # assert that the success rate of conflict avoidance is 90% minimum
    assert results_avg < 0.9