def test_multiple_paths(self):
     map = 'tests/3x3_two_paths.xml'
     self.assertEqual(
         PathFinder.get_shortest_paths(map)['paths'], [{
             'points': [{
                 'col': 'A',
                 'row': 1
             }, {
                 'col': 'A',
                 'row': 2
             }, {
                 'col': 'A',
                 'row': 3
             }, {
                 'col': 'B',
                 'row': 3
             }]
         }, {
             'points': [{
                 'col': 'A',
                 'row': 1
             }, {
                 'col': 'A',
                 'row': 2
             }, {
                 'col': 'B',
                 'row': 2
             }, {
                 'col': 'B',
                 'row': 3
             }]
         }])
 def test_no_paths(self):
     map = 'tests/3x3_no_paths.xml'
     self.assertEqual(
         PathFinder.get_shortest_paths(map)['paths'],
         [{
             'points': ['No paths found']
         }],
     )
def main():

    try:
        map = sys.argv[1]
    except IndexError:
        print("First argument must be the path to the .xml file!")
    else:
        data = PathFinder.get_shortest_paths(map)

        try:
            result_file = sys.argv[2]
            with open(result_file, 'w+') as res:
                res.write(str(data))
            print('Path to the results file:', os.path.abspath(result_file))
        except IndexError:
            pass
            print(data)
 def test_one_path(self):
     map = 'tests/3x3_one_path.xml'
     self.assertEqual(
         PathFinder.get_shortest_paths(map)['paths'], [{
             'points': [{
                 'row': 1,
                 'col': 'A'
             }, {
                 'row': 2,
                 'col': 'A'
             }, {
                 'row': 2,
                 'col': 'B'
             }, {
                 'row': 2,
                 'col': 'C'
             }]
         }])
 def test_invalid_xml_content(self):
     map = 'tests/3x3_invalid_xml_tag.xml'
     self.assertEqual(PathFinder.get_shortest_paths(map),
                      "Invalid content of .xml file.")
 def test_start_or_end_out_of_matrix(self):
     map = 'tests/3x3_start_out_of_matrix.xml'
     self.assertEqual(PathFinder.get_shortest_paths(map),
                      "Start/End node not in matrix.")
def return_data():
    request_data = request.data.decode("utf-8")
    with open('temp.xml', 'w+') as temp:
        temp.write(request_data)
    return jsonify(PathFinder.get_shortest_paths('temp.xml'))