def test_corrupt_cache_error(self): write_to_rendercache( self.workflow, self.step2, 2, make_table(make_column("A", [1])) ) delete_parquet_files_for_step(self.workflow.id, self.step2.id) response = self.client.get( f"/workflows/{self.workflow.id}/tiles/step-2/delta-2/0,0.json" ) self.assertEqual(response.status_code, status.NOT_FOUND) self.assertEqual( json.loads(response.content), {"error": "result went away; please try again with another delta_id"}, )
def test_missing_parquet_file(self): # https://www.pivotaltracker.com/story/show/161988744 cache_render_result( self.workflow, self.step2, self.step2.last_relevant_delta_id, RenderResult(arrow_table({"A": [1]})), ) # Simulate a race: we're overwriting the cache or deleting the Step # or some-such. delete_parquet_files_for_step(self.workflow.id, self.step2.id) response = self._request_step(self.step2) self.assertEqual(response.status_code, 200) self.assertEqual(json.loads(response.content), [])
def test_corrupt_cache_error(self): cache_render_result( self.workflow, self.step2, 2, RenderResult(arrow_table({"A": ["a", "b"]})), ) delete_parquet_files_for_step(self.workflow.id, self.step2.id) response = self.client.get( f"/workflows/{self.workflow.id}/tiles/step-2/delta-2/0,0.json") self.assertEqual(response.status_code, status.NOT_FOUND) self.assertEqual( json.loads(response.content), { "error": "result went away; please try again with another delta_id" }, )
def test_corrupt_cache(self): # https://www.pivotaltracker.com/story/show/161988744 cache_render_result( self.workflow, self.step1, self.step1.last_relevant_delta_id, RenderResult(arrow_table({"A": ["a"]})), ) # Simulate a race: we're overwriting the cache or deleting the Step # or some-such. delete_parquet_files_for_step(self.workflow.id, self.step1.id) response = self._request("A") # We _could_ return an empty result set; but our only goal here is # "don't crash" and this 404 seems to be the simplest implementation. # (We assume that if the data is deleted, the user has moved elsewhere # and this response is going to be ignored.) self.assertEqual(response.status_code, status.NOT_FOUND) self.assertEqual(json.loads(response.content), {"error": 'column "A" not found'})