Esempio n. 1
0
def test_locations_list_2():
    # Initialize locations with empty adjacency lists
    loc_1 = locations.Elevator([])
    loc_2 = locations.Staircase([])
    loc_3 = locations.Hallway([], [], 4)
    loc_4 = locations.Hallway([], [], 3)
    # Fill in adjacent locations
    loc_1.set_adj_list([loc_3])
    loc_2.set_adj_list([loc_4])
    loc_3.set_adj_list([loc_1, loc_4])
    loc_4.set_adj_list([loc_2, loc_3])
    # Test adj_list for loc_1 can chain to get adj list of loc_3
    assert loc_1.get_adj_list()[0].get_adj_list() == [loc_1, loc_4]
Esempio n. 2
0
def test_locations_list_1():
    # Initialize locations with empty adjacency lists
    loc_1 = locations.Elevator([])
    loc_2 = locations.Staircase([])
    loc_3 = locations.Hallway([], [], 4)
    loc_4 = locations.Hallway([], [], 3)
    # Fill in adjacent locations
    loc_1.set_adj_list([loc_3])
    loc_2.set_adj_list([loc_4])
    loc_3.set_adj_list([loc_1, loc_4])
    loc_4.set_adj_list([loc_2, loc_3])
    # Test adj_list for loc_1 works correctly
    assert loc_1.get_adj_list() == [loc_3]
def test_shortest_path_4():
    # Get the graph from the data loader for Stevenson
    graph = dl.graph
    # Get the start location as another location
    start = loc.Hallway()
    # Assert that there are no shortest path for the start location since it
    # is not in the graph
    assert sp.shortest_path(graph=graph, start=start) == False
Esempio n. 4
0
def test_set_room_list_1():
    adj_list = ["element1", "element2", "element3", "element4", "element5"]
    room_list = ["room1", "room2", "room3"]
    adj_list_new = [
        "element1", "element2", "element3", "element4", "element5", "element6"
    ]
    room_list_new = ["room1", "room2", "room3", "room4"]
    tester3 = locations.Hallway(adj_list, room_list, 5)
    tester3.set_room_list(room_list_new)
    tester3.set_length(4)
    tester3.set_adj_list(adj_list_new)
    assert tester3.get_room_list() == room_list_new
## hallwayX_Y: X = floor number, Y = end of hallway (1 = bottom half, 2 = top
#  half)
## elevatorX: X = which floor an elevator stops at

## Determining length of hallway was relative to how many classrooms were in
# 1 hallway.

from src import locations

#########################
## Initialize Locations##
#########################
## Floor 1 Locations
staircase1_1 = locations.Staircase(id_name="staircase1-2")

hallway1_1 = locations.Hallway(id_name="hallway1-1")

elevator1 = locations.Elevator(id_name="elevator1")

hallway1_2 = locations.Hallway(id_name="hallway1-2")

staircase1_2 = locations.Staircase(id_name="staircase1-2")

## Floor 2 Locations
staircase2_1 = locations.Staircase(id_name="staircase2-1")

hallway2_1 = locations.Hallway(id_name="hallway2-1")
elevator2 = locations.Elevator(id_name="elevator2")

# back area that leads outside
hallway2_2 = locations.Hallway(id_name="hallway2-2")
Esempio n. 6
0
def test_hallway_init_3():
    adj_list = ["element1", "element2", "element3", "element4", "element5"]
    room_list = ["room1", "room2", "room3"]
    tester3 = locations.Hallway(adj_list, room_list, 5)
    assert tester3.get_room_list() == room_list