Skip to content

Commit

Permalink
undo test_retrieve changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoumis committed Mar 6, 2024
1 parent 164968b commit 7106634
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions agent/test_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for the agent."""

import datetime
import http.client
import io
import multiprocessing
import os
Expand Down Expand Up @@ -31,14 +30,6 @@ def make_temp_name():
return str(uuid.uuid4())


def cause_gen(exc):
"""Examine chained exceptions."""
yield exc
while exc.__cause__:
exc = exc.__cause__
yield exc


class TestAgent:
"""Test the agent API."""

Expand Down Expand Up @@ -325,21 +316,10 @@ def test_retrieve(self):

# Retrieve the entire file; it comes back in a stream.
form = {"filepath": file_path}
received_data = ""
try:
# Can't use self.post_form here as no json will be returned.
r = requests.post(f"{BASE_URL}/retrieve", data=form)
assert r.status_code == 200
for line in r.iter_lines():
received_data = received_data + line.decode("utf-8")
except requests.exceptions.ChunkedEncodingError as e:
# Walk up the exception chain to get the partial chunk of data.
for prev_exception in cause_gen(e):
if isinstance(prev_exception, http.client.IncompleteRead):
received_data = received_data + prev_exception.partial.decode()

assert first_line in received_data
assert last_line in received_data
r = requests.post(f"{BASE_URL}/retrieve", data=form)
assert r.status_code == 200
assert first_line in r.text
assert last_line in r.text

def test_retrieve_invalid(self):
js = self.post_form("retrieve", {}, 400)
Expand Down

0 comments on commit 7106634

Please sign in to comment.