Permalink
Browse files

Remove Tile.__nonzero__

  • Loading branch information...
1 parent 8acfb92 commit a0b7506059eca005a89ee39e1442881f5a91575e @twpayne twpayne committed Apr 12, 2012
Showing with 24 additions and 21 deletions.
  1. +0 −2 tilecloud/__init__.py
  2. +0 −6 tilecloud/tests/test_tile.py
  3. +24 −13 tilecloud/tests/test_tilestore.py
View
@@ -304,8 +304,6 @@ def __init__(self, tilecoord, content_encoding=None, content_type=None,
for key, value in kwargs.iteritems():
setattr(self, key, value)
- def __nonzero__(self):
- return self.error is None
class TileStore(object):
@@ -15,9 +15,3 @@ def test_empty(self):
def test_init_kwargs(self):
tile = Tile(TileCoord(0, 0, 0), kwarg=None)
self.assertEqual(tile.kwarg, None)
-
- def test_nonzero(self):
- tile = Tile(TileCoord(0, 0, 0))
- self.assertTrue(tile)
- tile.error = True
- self.assertFalse(tile)
@@ -66,23 +66,29 @@ def test_one(self):
tilestream = [Tile(TileCoord(1, 0, 0), data='data'), None, Tile(TileCoord(1, 0, 1), error=True)]
tilestream = tile_store.put(tilestream)
tiles = list(tilestream)
- self.assertEqual(len(tiles), 1)
+ self.assertEqual(len(tiles), 2)
self.assertEqual(tiles[0].tilecoord, TileCoord(1, 0, 0))
self.assertEqual(tiles[0].data, 'data')
+ self.assertEqual(tiles[1].tilecoord, TileCoord(1, 0, 1))
+ self.assertEqual(tiles[1].error, True)
self.assertTrue(Tile(TileCoord(1, 0, 0)) in tile_store)
+ self.assertTrue(Tile(TileCoord(1, 0, 1)) in tile_store)
tilestream = [Tile(TileCoord(1, 0, 0)), Tile(TileCoord(1, 0, 1))]
tilestream = tile_store.get(tilestream)
consume(tilestream, None)
tiles = list(tile_store.get_all())
- self.assertEqual(len(tiles), 1)
+ self.assertEqual(len(tiles), 2)
self.assertEqual(tiles[0].tilecoord, TileCoord(1, 0, 0))
self.assertEqual(tiles[0].data, 'data')
+ self.assertEqual(tiles[1].tilecoord, TileCoord(1, 0, 1))
+ self.assertEqual(tiles[1].error, True)
tilestream = [Tile(TileCoord(1, 0, 0))]
tilestream = tile_store.delete(tilestream)
consume(tilestream, None)
tiles = list(tile_store.get_all())
- self.assertEqual(len(tiles), 0)
+ self.assertEqual(len(tiles), 1)
self.assertFalse(Tile(TileCoord(1, 0, 0)) in tile_store)
+ self.assertTrue(Tile(TileCoord(1, 0, 1)) in tile_store)
class TestMBTilesTileStore(unittest.TestCase):
@@ -93,30 +99,35 @@ def test_one(self):
tilestream = [Tile(TileCoord(1, 0, 0), data='data'), None, Tile(TileCoord(1, 0, 1), error=True)]
tilestream = tile_store.put(tilestream)
tiles = list(tilestream)
- self.assertEqual(tile_store.count(), 1)
- self.assertEqual(len(tiles), 1)
+ self.assertEqual(tile_store.count(), 2)
+ self.assertEqual(len(tiles), 2)
self.assertEqual(tiles[0].tilecoord, TileCoord(1, 0, 0))
self.assertEqual(tiles[0].data, 'data')
+ self.assertEqual(tiles[1].tilecoord, TileCoord(1, 0, 1))
+ self.assertEqual(tiles[1].error, True)
self.assertTrue(Tile(TileCoord(1, 0, 0)) in tile_store)
+ self.assertTrue(Tile(TileCoord(1, 0, 1)) in tile_store)
tilestream = [Tile(TileCoord(1, 0, 0)), Tile(TileCoord(1, 0, 1))]
tilestream = tile_store.get(tilestream)
consume(tilestream, None)
- self.assertEqual(tile_store.get_cheap_bounding_pyramid(), BoundingPyramid({1: (Bounds(0, 1), Bounds(0, 1))}))
- self.assertEqual(tile_store.count(), 1)
+ self.assertEqual(tile_store.get_cheap_bounding_pyramid(), BoundingPyramid({1: (Bounds(0, 1), Bounds(0, 2))}))
+ self.assertEqual(tile_store.count(), 2)
tiles = list(tile_store.list())
- self.assertEqual(len(tiles), 1)
- tiles = list(tile_store.get_all())
- self.assertEqual(tiles[0].tilecoord, TileCoord(1, 0, 0))
- self.assertEqual(len(tiles), 1)
+ self.assertEqual(len(tiles), 2)
+ tiles = sorted(tile_store.get_all())
+ self.assertEqual(len(tiles), 2)
self.assertEqual(tiles[0].tilecoord, TileCoord(1, 0, 0))
self.assertEqual(str(tiles[0].data), 'data')
+ self.assertEqual(tiles[1].tilecoord, TileCoord(1, 0, 1))
+ self.assertEqual(tiles[1].data, None)
tilestream = [Tile(TileCoord(1, 0, 0))]
tilestream = tile_store.delete(tilestream)
consume(tilestream, None)
- self.assertEqual(tile_store.count(), 0)
+ self.assertEqual(tile_store.count(), 1)
tiles = list(tile_store.get_all())
- self.assertEqual(len(tiles), 0)
+ self.assertEqual(len(tiles), 1)
self.assertFalse(Tile(TileCoord(1, 0, 0)) in tile_store)
+ self.assertTrue(Tile(TileCoord(1, 0, 1)) in tile_store)
def test_metadata(self):
tile_store = MBTilesTileStore(sqlite3.connect(':memory:'))

0 comments on commit a0b7506

Please sign in to comment.