Commit 8adba02b authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

exception when command returns error

parent 7b8716e4
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -86,6 +86,12 @@ class FilesysBroker(RemoteDataBroker):
                    assert process.stdout is not None
                    chunk = process.stdout.read(4096)
                    if not chunk:
                        process.wait()
                        if process.returncode != 0:
                            raise HTTPException(
                                status_code=500,
                                detail="cat file command returned error",
                            )
                        break
                    yield chunk

+10 −0
Original line number Diff line number Diff line
@@ -122,6 +122,16 @@ class TestFilesysBroker:
            async for chunk in res.body_iterator:
                response_body += chunk

    @pytest.mark.asyncio
    async def test_filesys_downloadfailnofile(self, _tear_up_down: Any) -> None:
        settings.rdb_cat_cmd = "cat"
        with pytest.raises(HTTPException):
            self.download_data.filename = "nonexist"
            res = self.broker.download(self.download_data)
            response_body = b""
            async for chunk in res.body_iterator:
                response_body += chunk

    def test_filesys_delete(self, _tear_up_down: Any) -> None:
        self.broker.upload(self.upload_data)