Ejemplo n.º 1
0
def test_no_user_has_self_as_neighbor():
    graph = CoachingGraph()
    graph.init_semi_random(100)
    for user in graph.users:
        if user in user.neighbors:
            assert False
    assert True
Ejemplo n.º 2
0
def test_no_user_has_self_as_neighbor():
	graph = CoachingGraph()
	graph.init_semi_random(100)
	for user in graph.users:
		if user in user.neighbors:
			assert False
	assert True
Ejemplo n.º 3
0
def test_save_and_load():
    graph = CoachingGraph()
    graph.init_semi_random(100)
    graph.save_as('save_and_load')
    graphB = CoachingGraph()
    graphB.load_from('save_and_load')

    assert len(graph.users) == len(graphB.users)
Ejemplo n.º 4
0
def test_save_and_load():
	graph = CoachingGraph()
	graph.init_semi_random(100)
	graph.save_as('save_and_load')
	graphB = CoachingGraph()
	graphB.load_from('save_and_load')

	assert len(graph.users) == len(graphB.users)
Ejemplo n.º 5
0
def test_get_num_infected_large():
	expectedInfected = 100
	graph = CoachingGraph()
	graph.init_semi_random(expectedInfected)
	infecter = Infecter()

	infecter.infect_all(graph.users)
	actualInfected = infecter.get_num_infected(graph.users)

	assert actualInfected == expectedInfected
Ejemplo n.º 6
0
def test_infect_limited_doesnt_change_num_users():
	originalUsers = 100
	graph = CoachingGraph()
	graph.init_semi_random(originalUsers)
	infecter = Infecter()

	infecter.infect_limited(graph.users, 50, 10)
	remaingingUsers = len(graph.users)

	assert remaingingUsers == originalUsers
Ejemplo n.º 7
0
def test_infect_limited_infects_correct_number():
	graph = CoachingGraph()
	graph.init_semi_random(200)
	numToInfect = 70
	users = graph.users
	infecter = Infecter()

	infecter.infect_limited(users, numToInfect, 0, False)
	numInfected = infecter.get_num_infected(users)

	assert numInfected == numToInfect
Ejemplo n.º 8
0
def generate_test_graphs(dirName, numGraphs, maxSize):
	logger.info("generating test graphs in directory: {}".format(dirName))
	folderPath = refresh_testData_folder(dirName)
	graphs = []
	for i in range(numGraphs):
		graph = CoachingGraph()

		fileNumber = i + 1
		fileName = '{}_'.format(fileNumber) + TEST_GRAPH_SUFFIX

		randomSize = random.randint(100, maxSize)
		randomInternalConnections = random.randint(2, 12)
		randomCoacheesFactor = random.randint(2, 5)
		graph.init_semi_random(200, randomInternalConnections, randomCoacheesFactor)
		graphs.append(graph)
		filePath = os.path.join(folderPath, fileName)
		graph.save_as(filePath)
	return graphs
Ejemplo n.º 9
0
def generate_test_graphs(dirName, numGraphs, maxSize):
    logger.info("generating test graphs in directory: {}".format(dirName))
    folderPath = refresh_testData_folder(dirName)
    graphs = []
    for i in range(numGraphs):
        graph = CoachingGraph()

        fileNumber = i + 1
        fileName = '{}_'.format(fileNumber) + TEST_GRAPH_SUFFIX

        randomSize = random.randint(100, maxSize)
        randomInternalConnections = random.randint(2, 12)
        randomCoacheesFactor = random.randint(2, 5)
        graph.init_semi_random(200, randomInternalConnections,
                               randomCoacheesFactor)
        graphs.append(graph)
        filePath = os.path.join(folderPath, fileName)
        graph.save_as(filePath)
    return graphs
Ejemplo n.º 10
0
def resource_semi_random_graph_users():
	graph = CoachingGraph()
	graph.init_semi_random(200)

	return graph.users
Ejemplo n.º 11
0
def test_semi_random_graph():
    graph = CoachingGraph()
    graph.init_semi_random(20)

    assert len(graph.users) == 20
Ejemplo n.º 12
0
def test_semi_random_graph():
	graph = CoachingGraph()
	graph.init_semi_random(20)

	assert len(graph.users) == 20