class TestDbPolygons(unittest.TestCase): def setUp(self): self.db = RiakDb() self.db.create_user(U_EMAIL, U_NAME, U_PASS, U_ADDR) p = self.db.create_polygon("Nevada", "Area 51", U_EMAIL, date.today(), None, ['type1', 'typeB']) self.poly_id = p['id'] def tearDown(self): self.db.delete_polygon(self.poly_id) self.db.delete_user(U_EMAIL) def test_get_own_polygon(self): poly = self.db.get_polygon(self.poly_id, U_EMAIL) self.assertEqual(poly['name'], "Area 51") self.assertEqual(poly['type'], ['type1', 'typeB']) def test_polygon_start_date_as_datetime(self): dt = self.db.get_polygon(self.poly_id, U_EMAIL)['start_date'] self.assertEqual(dt, date.today()) def test_get_other_polygon(self): self.assertIsNone(self.db.get_polygon(self.poly_id, "wrong_user")) def test_delete_polygon(self): self.db.delete_polygon(self.poly_id) self.assertIsNone(self.db.get_polygon(self.poly_id, U_EMAIL))
class TestDbPolygonTypes(unittest.TestCase): def setUp(self): self.db = RiakDb() self.db.create_poly_type("Test", False, None, ["child1", "child2"]) def tearDown(self): self.db.delete_polygon("Test") self.db.delete_user(U_EMAIL) def test_get_poly_type(self): self.assertEqual( self.db.get_poly_type("Test")['children'][0], "child1") # TODO: test_get_deleted_poly_type def test_delete_poly_type(self): self.db.delete_poly_type("Test") self.assertIsNone(self.db.get_poly_type("Test"))