Ejemplo n.º 1
0
    def test_known_site(self):
        args = [ 'pytopo', 'san-francisco' ]

        with open(os.path.join(self.configdir, 'pytopo', 'pytopo.sites'),
                  "w") as cfp:
            cfp.write('''Collections = [
    OSMMapCollection( "humanitarian", "~/Maps/humanitarian",
                      ".png", 256, 256, 13,
                      "http://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",
                      maxzoom=15,
                      attribution="Humanitarian OSM Maps, map data © OpenStreetMap contributors"),
    ]

# Default to whichever MapCollection is listed first.
defaultCollection = Collections[0].name

KnownSites = [
    [ "san-francisco", -122.245, 37.471, "", 11 ],
    ]''')

        mapwin =  MapWindow(self.viewer)
        self.viewer.parse_args(mapwin, args)

        self.assertEqual(len(mapwin.trackpoints.points), 0)
        self.assertEqual(len(mapwin.trackpoints.waypoints), 0)
        # XXX The default san-francisco coordinates are 37.471, -122.245
        # so it's not entirely clear why that isn't the center location.
        # That's not the case in the test_explicit_coords case,
        # where the center is exactly the coordinates specified.
        # Investigate this.
        self.assertCloseEnough(mapwin.center_lon, -122.4083)
        self.assertCloseEnough(mapwin.center_lat, 37.7850)
Ejemplo n.º 2
0
    def test_explicit_coords_plus_gpx(self):
        args = [ 'pytopo', '35.85', '-106.4', '-t',
                 'test/files/otowi-mesa-arch.gpx' ]

        mapwin =  MapWindow(self.viewer)
        self.viewer.parse_args(mapwin, args)

        self.assertEqual(len(mapwin.trackpoints.points), 1265)
        self.assertEqual(len(mapwin.trackpoints.waypoints), 2)
        self.assertCloseEnough(mapwin.center_lon, -106.4)
        self.assertCloseEnough(mapwin.center_lat, 35.85)
Ejemplo n.º 3
0
    def test_bogus_args(self):
        arglists = [ [ 'pytopo', 'test/test_argparsing.py' ],
                     [ 'pytopo', 'rumplestiltskin' ],
                     [ 'pytopo', '35.0', 'xyz' ],
                   ]

        for args in arglists:
            mapwin =  MapWindow(self.viewer)

            try:
                self.viewer.parse_args(mapwin, args)
                self.assertEqual("Should have barfed on the bogus args ["
                                 + ', '.join(args) + "]", None)

            except ArgParseException:
                print("ArgParseException, good")

            except SystemExit:
                print("SystemExit, fine")