def test_agent_upload_multipart(init_agent): multipart_form_data = {'file': ("room.csv", BytesIO(b'Room1;23;710'))} response = requests.post( 'http://127.0.0.1:8880/upload', files=multipart_form_data) assert response.status_code == 200 assert agent.stats == NgsiAgent.Stats(1, 1, 1, 0, 0, 0) agent.stats.zero()
def test_agent_upload_multipart_excel(init_agent): filename = pkg_resources.resource_filename(__name__, "data/test.xlsx") multipart_form_data = {'file': ("test.xlsx", open(filename, 'rb'))} response = requests.post( 'http://127.0.0.1:8880/upload', files=multipart_form_data) assert response.status_code == 200 assert agent.stats == NgsiAgent.Stats(4, 4, 4, 0, 0, 0) agent.stats.zero()
def test_upload_raw_json(init_agent): data = { 'room': 'Room1', 'temperature': 23.0, 'pressure': 710} response = requests.post('http://127.0.0.1:8880/upload', json=data) assert response.status_code == 200 assert agent.stats == NgsiAgent.Stats(1, 1, 1, 0, 0, 0) agent.stats.zero()
def __init__(self): self.starttime = datetime.now() self.stats = NgsiAgent.Stats()