def test_http_headers(): worker = HTTPFileSubmitter(tmpdir, tmpdir) with HTTPServe() as served: worker.run_action(url="http://*****:*****@x-my-header': 'foo'}) assert served.headers['x-my-header'] == 'foo'
def test_run_action_503(): file_path = os.path.join(tmpdir, 'test.txt') with open(file_path, 'w') as f: f.write("My text !\n") worker = HTTPFileSubmitter(tmpdir, tmpdir) with HTTPServe() as served: with pytest.raises(Exception): worker.run_action(url="http://localhost:8888", file_path=file_path, do_raise='yes')
def test_run_action(): """just test the action is working""" file_path = os.path.join(tmpdir, 'test.txt') with open(file_path, 'w') as f: f.write("My text !\n") worker = HTTPFileSubmitter(tmpdir, tmpdir) with HTTPServe() as served: worker.run_action(url="http://localhost:8888", file_path=file_path) assert 'filename="test.txt"' in served.data assert "My text !\n" in served.data assert served.headers['Content-Type'].startswith('multipart/form-data')
def test_run_action_additional_params(): """just test the action is working with additional params""" file_path = os.path.join(tmpdir, 'test.txt') with open(file_path, 'w') as f: f.write("My text !\n") worker = HTTPFileSubmitter(tmpdir, tmpdir) with HTTPServe() as served: worker.run_action(url="http://localhost:8888", file_path=file_path, param1='foo', param2='bar') assert 'filename="test.txt"' in served.data assert 'name="param1"' in served.data assert 'foo' in served.data assert 'name="param2"' in served.data assert 'bar' in served.data