コード例 #1
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
コード例 #2
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #3
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #4
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
コード例 #5
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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
コード例 #6
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
     )
コード例 #7
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
     )
コード例 #8
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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
コード例 #9
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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
コード例 #10
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
     )
コード例 #11
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
     )
コード例 #12
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
     )
コード例 #13
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
     )
コード例 #14
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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"
     )
コード例 #15
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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"
     )
コード例 #16
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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"
         )
コード例 #17
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
     )
コード例 #18
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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"
         )
コード例 #19
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
     )
コード例 #20
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
     )
コード例 #21
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
     )
コード例 #22
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #23
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #24
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #25
0
ファイル: test_edist.py プロジェクト: JNRowe/upoints
 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'
コード例 #26
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #27
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #28
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #29
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'
コード例 #30
0
ファイル: test_edist.py プロジェクト: encukou/upoints
 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'