예제 #1
0
    def test_get_cheapest_path(self):
        expected = deque(['GRU', 'BRC', 'SCL', 'ORL', 'CDG'])

        csv_content_mock = [['GRU', 'BRC', '10'], ['BRC', 'SCL', '5'],
                            ['GRU', 'CDG', '75'], ['GRU', 'SCL', '20'],
                            ['GRU', 'ORL', '56'], ['ORL', 'CDG', '53'],
                            ['ORL', 'CDG', '8'], ['SCL', 'ORL', '20']]

        routes = Routes(csv_content_mock)

        cheapest_path = routes.get_cheapest_path('GRU', 'CDG')

        assert cheapest_path == expected
예제 #2
0
    def start(self):
        csv_content = self.read_csv_file(sys.argv[1])

        routes = Routes(csv_content)

        goal = parse_origin_goal(goal=sys.argv[2])

        try:
            best_path = routes.get_cheapest_path(goal[0], goal[1])
        except csv.Error as e:
            sys.exit('%s' % (e))

        formatted_best_path = format_output(best_path)
        print('best route: ' + formatted_best_path)

        sys.exit(0)