Exemplo n.º 1
0
 def test_display_non_verbose(self, capsys):
     locs = NumberedPoints(['Home', '52.168;0.040'],
                           config_locations={'Home': (52.015, -0.221)})
     locs.format = 'locator'
     locs.verbose = False
     locs.display('extsquare')
     assert capsys.readouterr()[0] == 'IO92va33\nJO02ae40\n'
Exemplo n.º 2
0
 def test_display_non_verbose(self, stdout):
     locs = NumberedPoints(['Home', '52.168;0.040'],
                           config_locations={'Home': (52.015, -0.221)})
     locs.format = 'locator'
     locs.verbose = False
     locs.display('extsquare')
     expect(stdout.getvalue()) == 'IO92va33\nJO02ae40\n'
Exemplo n.º 3
0
 def test_distance_nm(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'],
                                units='nm')
     locations.verbose = False
     locations.distance()
     # Manually convert to string here to workaround Python 2/3 float
     # formatting differences
     expect(stdout.getvalue()) == str(13.298957431655218) + '\n'
Exemplo n.º 4
0
 def test_final_bearing(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.bearing('final_bearing', False)
     if PY2:
         output = capsys.readouterr()[0].encode('utf-8')
     else:
         output = capsys.readouterr()[0]
     assert output == 'Final bearing from location 1 to 2 is 46°\n'
Exemplo n.º 5
0
 def test_sunset(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.sun_events('sunset')
     lines = capsys.readouterr()[0].splitlines()
     assert ellipsis_match('Sunset at ... in location 1', lines[0]) \
         == True
     assert ellipsis_match('Sunset at ... in location 2', lines[1]) \
         == True
Exemplo n.º 6
0
 def test_destination_locator(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.format = 'locator'
     locations.destination(42, 240, 'subsquare')
     expect(stdout.getvalue()) == (
         'Destination from location 1 is IO91ot\n'
         'Destination from location 2 is IO91sx\n'
     )
Exemplo n.º 7
0
 def test_destination_locator(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.format = 'locator'
     locations.destination(42, 240, 'subsquare')
     assert capsys.readouterr()[0] == (
         'Destination from location 1 is IO91ot\n'
         'Destination from location 2 is IO91sx\n'
     )
Exemplo n.º 8
0
 def test_sunset(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.sun_events('sunset')
     lines = stdout.getvalue().splitlines()
     expect(ellipsis_match('Sunset at ... in location 1', lines[0])) \
         == True
     expect(ellipsis_match('Sunset at ... in location 2', lines[1])) \
         == True
Exemplo n.º 9
0
 def test_range(self, distance, result, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.range(distance)
     stdout = capsys.readouterr()[0]
     if result is True:
         assert 'is within' in stdout
     else:
         assert 'is not within' in stdout
Exemplo n.º 10
0
 def test_display_locator(self, capsys):
     locs = NumberedPoints(['Home', '52.168;0.040'],
                           config_locations={'Home': (52.015, -0.221)})
     locs.format = 'locator'
     locs.display('extsquare')
     assert capsys.readouterr()[0] == (
         'Location Home is IO92va33\n'
         'Location 2 is JO02ae40\n'
     )
Exemplo n.º 11
0
 def test_distance_multi(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040',
                                '51.420;-1.500'])
     locations.distance()
     expect(stdout.getvalue()) == (
         'Location 1 to 2 is 24 kilometres\n'
         'Location 2 to 3 is 134 kilometres\n'
         'Total distance is 159 kilometres\n'
     )
Exemplo n.º 12
0
 def test_display_locator(self, stdout):
     locs = NumberedPoints(['Home', '52.168;0.040'],
                           config_locations={'Home': (52.015, -0.221)})
     locs.format = 'locator'
     locs.display('extsquare')
     expect(stdout.getvalue()) == (
         'Location Home is IO92va33\n'
         'Location 2 is JO02ae40\n'
     )
Exemplo n.º 13
0
 def test_distance_multi(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040',
                                 '51.420;-1.500'])
     locations.distance()
     assert capsys.readouterr()[0] == (
         'Location 1 to 2 is 24 kilometres\n'
         'Location 2 to 3 is 134 kilometres\n'
         'Total distance is 159 kilometres\n'
     )
Exemplo n.º 14
0
 def test_destination(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.destination(42, 240, False)
     stdout = capsys.readouterr()[0]
     if PY2:
         stdout = stdout.encode('utf-8')
     assert stdout == (
         "Destination from location 1 is 52°00.90'N, 000°13.26'W\n"
         "Destination from location 2 is 52°10.08'N, 000°02.40'E\n"
     )
Exemplo n.º 15
0
 def test_display(self, capsys):
     locs = NumberedPoints(['Home', '52.168;0.040'],
                           config_locations={'Home': (52.015, -0.221)})
     locs.display(None)
     stdout = capsys.readouterr()[0]
     if PY2:
         stdout = stdout.encode('utf-8')
     assert stdout == (
         "Location Home is 52°00.90'N, 000°13.26'W\n"
         "Location 2 is 52°10.08'N, 000°02.40'E\n"
     )
Exemplo n.º 16
0
 def test_destination(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.destination(42, 240, False)
     if PY2:
         expect(stdout.getvalue()) == (
             "Destination from location 1 is 52\xc2\xb000.90'N, 000\xc2\xb013.26'W\n"
             "Destination from location 2 is 52\xc2\xb010.08'N, 000\xc2\xb002.40'E\n"
         )
     else:
         expect(stdout.getvalue()) == (
             "Destination from location 1 is 52°00.90'N, 000°13.26'W\n"
             "Destination from location 2 is 52°10.08'N, 000°02.40'E\n"
         )
Exemplo n.º 17
0
 def test_flight_plan(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040',
                                '52.249;0.130', '52.494;0.654'])
     locations.flight_plan(0, 'h')
     expect(stdout.getvalue()) == (
         'WAYPOINT,BEARING[°],DISTANCE[km],ELAPSED_TIME[h],LATITUDE[d.dd],LONGITUDE[d.dd]\n'
         '1,,,,52.015000,-0.221000\n'
         '2,46,24.6,,52.168000,0.040000\n'
         '3,34,10.9,,52.249000,0.130000\n'
         '4,52,44.8,,52.494000,0.654000\n'
         '-- OVERALL --#,,80.3,,,\n'
         '-- DIRECT --#,47,79.9,,,\n'
     )
Exemplo n.º 18
0
 def test_display(self, stdout):
     locs = NumberedPoints(['Home', '52.168;0.040'],
                           config_locations={'Home': (52.015, -0.221)})
     locs.display(None)
     if PY2:
         expect(stdout.getvalue()) == (
             "Location Home is 52\xc2\xb000.90'N, 000\xc2\xb013.26'W\n"
             "Location 2 is 52\xc2\xb010.08'N, 000\xc2\xb002.40'E\n"
         )
     else:
         expect(stdout.getvalue()) == (
             "Location Home is 52°00.90'N, 000°13.26'W\n"
             "Location 2 is 52°10.08'N, 000°02.40'E\n"
         )
Exemplo n.º 19
0
 def test_flight_plan_minute(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040',
                                 '52.249;0.130', '52.494;0.654'],
                                units='nm')
     locations.flight_plan(20, 'm')
     expect(stdout.getvalue()) == (
         'WAYPOINT,BEARING[°],DISTANCE[nm],ELAPSED_TIME[m],LATITUDE[d.dd],LONGITUDE[d.dd]\n'
         '1,,,,52.015000,-0.221000\n'
         '2,46,13.3,0.7,52.168000,0.040000\n'
         '3,34,5.9,0.3,52.249000,0.130000\n'
         '4,52,24.2,1.2,52.494000,0.654000\n'
         '-- OVERALL --,,43.4,2.2,,\n'
         '-- DIRECT --,47,43.1,2.2,,\n'
     )
Exemplo n.º 20
0
 def test_flight_plan(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040',
                                 '52.249;0.130', '52.494;0.654'])
     locations.flight_plan(0, 'h')
     if PY2:
         output = capsys.readouterr()[0].encode('utf-8')
     else:
         output = capsys.readouterr()[0]
     assert output == (
         'WAYPOINT,BEARING[°],DISTANCE[km],ELAPSED_TIME[h],LATITUDE[d.dd],LONGITUDE[d.dd]\n'
         '1,,,,52.015000,-0.221000\n'
         '2,46,24.6,,52.168000,0.040000\n'
         '3,34,10.9,,52.249000,0.130000\n'
         '4,52,44.8,,52.494000,0.654000\n'
         '-- OVERALL --#,,80.3,,,\n'
         '-- DIRECT --#,47,79.9,,,\n'
     )
Exemplo n.º 21
0
 def test_flight_plan_minute(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040',
                                 '52.249;0.130', '52.494;0.654'],
                                units='nm')
     locations.flight_plan(20, 'm')
     if PY2:
         output = capsys.readouterr()[0].encode('utf-8')
     else:
         output = capsys.readouterr()[0]
     assert output == (
         'WAYPOINT,BEARING[°],DISTANCE[nm],ELAPSED_TIME[m],LATITUDE[d.dd],LONGITUDE[d.dd]\n'
         '1,,,,52.015000,-0.221000\n'
         '2,46,13.3,0.7,52.168000,0.040000\n'
         '3,34,5.9,0.3,52.249000,0.130000\n'
         '4,52,24.2,1.2,52.494000,0.654000\n'
         '-- OVERALL --,,43.4,2.2,,\n'
         '-- DIRECT --,47,43.1,2.2,,\n'
     )
Exemplo n.º 22
0
 def test_range_non_verbose(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.verbose = False
     locations.range(30)
     expect(stdout.getvalue()) == 'True\n'
Exemplo n.º 23
0
 def test_distance_sm(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'],
                                units='sm')
     locations.distance()
     expect(stdout.getvalue()) == 'Location 1 to 2 is 15 miles\n'
Exemplo n.º 24
0
 def test_destination_locator_non_verbose(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.format = 'locator'
     locations.verbose = False
     locations.destination(42, 240, 'extsquare')
     expect(stdout.getvalue()) == 'IO91ot97\nIO91sx14\n'
Exemplo n.º 25
0
 def test_destination_locator_non_verbose(self, capsys):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.format = 'locator'
     locations.verbose = False
     locations.destination(42, 240, 'extsquare')
     assert capsys.readouterr()[0] == 'IO91ot97\nIO91sx14\n'
Exemplo n.º 26
0
 def test_distance(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.distance()
     expect(stdout.getvalue()) == 'Location 1 to 2 is 24 kilometres\n'
Exemplo n.º 27
0
 def test_range2(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.range(30)
     expect(stdout.getvalue()) == \
         'Location 2 is within 30 kilometres of location 1\n'
Exemplo n.º 28
0
 def test_final_bearing_non_verbose(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.verbose = False
     locations.bearing('final_bearing', True)
     expect(stdout.getvalue()) == 'North-east\n'
Exemplo n.º 29
0
 def test_final_bearing_symbolic(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.bearing('final_bearing', True)
     expect(stdout.getvalue()) == \
         'Final bearing from location 1 to 2 is North-east\n'
Exemplo n.º 30
0
 def test_final_bearing(self, stdout):
     locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'])
     locations.bearing('final_bearing', False)
     expect(stdout.getvalue()) == \
         'Final bearing from location 1 to 2 is 46°\n'