Exemplo n.º 1
0
    def testFSPNormal(self):
        """
        Bunch of tests that check "normal" behaviour of the function (correct inquiry, correct data).
        """
        global conn, curs
        # 1) Supply random src_node_id != dest_node_id, so that the path is at least MIN_DIST)
        # nodes long. Verify that :
        #   -- check if distance is found correctly;
        #   -- for each path segment, check if end node of the current segment is the start node of
        #      the next segment;
        #   -- check if endpoints of each segment indeed have distance = 1 (by querying DB);
        #   -- do it several times?
        MIN_DIST = 7
        SQL_QUERY_TESTING_SAMPLE = "SELECT DISTINCT src_node_id, dest_node_id, distance "\
        + "FROM routing_table WHERE distance > %s" % MIN_DIST
        curs.execute(SQL_QUERY_TESTING_SAMPLE)
        sample = curs.fetchone()
        src_node_id = sample[0]
        dest_node_id = sample[1]
        distance = sample[2]

        d, shortestPath = find_shortest_path(src_node_id, dest_node_id)
        # print "%s" % shortestPath
        self.assertEquals(d, len(shortestPath))
        self.assertEquals(d, distance)

        print "FOR GOD'S SAKE, FINISH THIS FREAKIN' TEST CODE!!! :)"
        raise
 def testFSPNormal(self):
     """
     Bunch of tests that check "normal" behaviour of the function (correct inquiry, correct data).
     """
     global conn, curs
     # 1) Supply random src_node_id != dest_node_id, so that the path is at least MIN_DIST) 
     # nodes long. Verify that :
     #   -- check if distance is found correctly;
     #   -- for each path segment, check if end node of the current segment is the start node of
     #      the next segment;
     #   -- check if endpoints of each segment indeed have distance = 1 (by querying DB);
     #   -- do it several times?
     MIN_DIST = 7
     SQL_QUERY_TESTING_SAMPLE = "SELECT DISTINCT src_node_id, dest_node_id, distance "\
     + "FROM routing_table WHERE distance > %s" % MIN_DIST
     curs.execute(SQL_QUERY_TESTING_SAMPLE)
     sample = curs.fetchone()
     src_node_id = sample[0]
     dest_node_id = sample[1]
     distance = sample[2]
     
     d, shortestPath = find_shortest_path(src_node_id, dest_node_id)
     # print "%s" % shortestPath
     self.assertEquals(d, len(shortestPath))
     self.assertEquals(d, distance)
     
     print "FOR GOD'S SAKE, FINISH THIS FREAKIN' TEST CODE!!! :)"
     raise
Exemplo n.º 3
0
from routing.pathfinder import find_shortest_path
import sys

src_node_id = int(sys.argv[1])
dest_node_id = int(sys.argv[2])

#src_node_id = 3339
#dest_node_id = 4867
d, res = find_shortest_path(src_node_id, dest_node_id)

#print "sys.argv = %s" % sys.argv
print "src_node_id = %s" % src_node_id
print "dest_node_id = %s" % dest_node_id
print "Distance: %d" % d
print "%s" % res