Exemplo n.º 1
0
 def setUp(self):
     self.gc = Geocaching()
     self.t = Trackable("TB1234", self.gc, name="TrackMe")
     self.c = Cache("GC12345",
                    self.gc,
                    name="Testing",
                    cache_type="Traditional Cache",
                    location=Point(),
                    state=True,
                    found=False,
                    size="micro",
                    difficulty=1.5,
                    terrain=5,
                    author="human",
                    hidden=date(2000, 1, 1),
                    attributes={
                        "onehour": True,
                        "kids": False,
                        "available": True
                    },
                    summary="text",
                    description="long text",
                    hint="rot13",
                    favorites=0,
                    pm_only=False,
                    trackables=self.t)
Exemplo n.º 2
0
    def test_blocks(self, mock_utfgrid):
        """Parse locally stored grid and compare to expected results"""

        # load mock utfgrid from file
        with open(_sample_utfgrid_file) as f:
            mock_utfgrid.return_value = json.load(f)

        # load expected caches from file
        expected_caches = {}
        with open(_sample_caches_file) as f:
            for row in f:
                wp, lat, lon, pm_only = row.strip().split(",")
                expected_caches[wp] = float(lat), float(lon), bool(int(pm_only))

        for b in self.tile.blocks:
            c = Cache.from_block(b)
            self.assertIn(c.wp, expected_caches)
            if not expected_caches[c.wp][2]:  # if not PM only
                self.assertAlmostEqual(c.location.latitude, expected_caches[
                    c.wp][0], self.POSITION_ACCURANCY)
                self.assertAlmostEqual(c.location.longitude, expected_caches[
                    c.wp][1], self.POSITION_ACCURANCY)
            expected_caches.pop(c.wp)
        self.assertEqual(len(expected_caches), 0)
Exemplo n.º 3
0
 def test_geocaching(self):
     with self.assertRaises(ValueError):
         Cache("GC12345", None)
Exemplo n.º 4
0
 def test___eq__(self):
     self.assertEqual(self.c, Cache("GC12345", self.gc))