def test_boundaries_deprecation(self):
        with warnings.catch_warnings(record=True) as w:
            do = DataObsClient(self.credentials)

        with warnings.catch_warnings(record=True) as w:
            try:
                do.boundaries()
            except Exception:
                pass

            assert issubclass(w[-1].category, DeprecationWarning)
            assert 'deprecated' in str(w[-1].message)
    def test_boundaries(self):
        """DataObsClient.boundaries"""
        do = DataObsClient(self.credentials)

        # all boundary metadata
        boundary_meta = do.boundaries()
        self.assertTrue(boundary_meta.shape[0] > 0,
                        msg='has non-zero number of boundaries')
        meta_cols = set((
            'geom_id',
            'geom_tags',
            'geom_type',
        ))
        self.assertTrue(meta_cols & set(boundary_meta.columns))

        # boundary metadata with correct timespan
        meta_2015 = do.boundaries(timespan='2015')
        self.assertTrue(meta_2015[meta_2015.valid_timespan].shape[0] > 0)

        # test for no data with an incorrect or invalid timespan
        meta_9999 = do.boundaries(timespan='invalid_timespan')
        self.assertTrue(meta_9999[meta_9999.valid_timespan].shape[0] == 0)

        # boundary metadata in a region
        regions = (
            self.test_read_table,
            self.test_data_table,
            [5.9559111595, 45.8179931641, 10.4920501709, 47.808380127],
            'Australia',
        )
        for region in regions:
            boundary_meta = do.boundaries(region=region)
            self.assertTrue(meta_cols & set(boundary_meta.columns))
            self.assertTrue(boundary_meta.shape[0] > 0,
                            msg='has non-zero number of boundaries')

        #  boundaries for world
        boundaries = do.boundaries(boundary='us.census.tiger.state')
        self.assertTrue(boundaries.shape[0] > 0)
        self.assertEqual(boundaries.shape[1], 2)
        self.assertSetEqual(set((
            'the_geom',
            'geom_refs',
        )), set(boundaries.columns))

        # boundaries for region
        boundaries = ('us.census.tiger.state', )
        for b in boundaries:
            geoms = do.boundaries(boundary=b, region=self.test_data_table)
            self.assertTrue(geoms.shape[0] > 0)
            self.assertEqual(geoms.shape[1], 2)
            self.assertSetEqual(set((
                'the_geom',
                'geom_refs',
            )), set(geoms.columns))

        # presence or lack of clipped boundaries
        nonclipped = (
            True,
            False,
        )
        for tf in nonclipped:
            meta = do.boundaries(include_nonclipped=tf)
            self.assertEqual('us.census.tiger.state' in set(meta.geom_id), tf)

        with self.assertRaises(ValueError):
            do.boundaries(region=[1, 2, 3])

        with self.assertRaises(ValueError):
            do.boundaries(region=10)