def test_batch_log_from_json(): batch_log_json = { "id": 2398, "from": 100, "total": 100, "log": ["log1", "log2"], } expected = BatchLog(batch_id=2398, from_=100, total=100, lines=["log1", "log2"]) assert BatchLog.from_json(batch_log_json) == expected
def get_batch_log( self, batch_id: int, from_: int = None, size: int = None ) -> Optional[BatchLog]: """Get logs for a batch. :param batch_id: The ID of the batch. :param from_: The line number to start getting logs from. :param size: The number of lines of logs to get. """ params = {} if from_ is not None: params["from"] = from_ if size is not None: params["size"] = size try: data = self._client.get(f"/batches/{batch_id}/log", params=params) except requests.HTTPError as e: if e.response.status_code == 404: return None else: raise return BatchLog.from_json(data)
def test_batch_log_from_json_no_log(): batch_log_json = {"id": 2398, "from": 0, "total": 100} expected = BatchLog(batch_id=2398, from_=0, total=100, lines=[]) assert BatchLog.from_json(batch_log_json) == expected