def test_ndarray_blosc(self):
     expected_metadata = {"foo": "bar"}
     expected_array = np.zeros((2, 2))
     content = self.create_blosc_response(expected_metadata, expected_array)
     self.mock_response(responses.POST,
                        json=None,
                        body=content,
                        stream=True)
     array, meta = self.raster.ndarray(["fakeid"])
     self.assertEqual(expected_metadata, meta)
     np.testing.assert_array_equal(expected_array, array)
 def test_ndarray_no_blosc(self):
     expected_array = np.zeros((2, 2))
     expected_metadata = {"foo": "bar"}
     content = io.BytesIO()
     np.savez(content,
              data=expected_array,
              metadata=json.dumps(expected_metadata).encode("utf-8"))
     self.mock_response(responses.POST, json=None, body=content.getvalue())
     array, meta = self.raster.ndarray(["fakeid"])
     self.assertEqual(expected_metadata, meta)
     np.testing.assert_array_equal(expected_array, array)
 def do_stack(self, **stack_args):
     expected_metadata = {"foo": "bar"}
     expected_array = np.zeros((2, 2, 1))
     content = self.create_blosc_response(expected_metadata, expected_array)
     self.mock_response(responses.POST,
                        json=None,
                        body=content,
                        stream=True)
     stack, meta = self.raster.stack([["fakeid"], ["fakeid2"]],
                                     order="gdal",
                                     **stack_args)
     np.testing.assert_array_equal(expected_array, stack[0, :])
     np.testing.assert_array_equal(expected_array, stack[1, :])
     self.assertEqual([expected_metadata] * 2, meta)