87826c4ccb971911752adbc4bdac8d3e7c28989e,tests/test_utils.py,,test_endpoint_config,#Any#,84
Before Change
timeout=30000
)
httpretty.register_uri(
httpretty.POST,
"https://abc.defg/test",
status=500,
body="")
httpretty.enable()
loop.run_until_complete(endpoint.request("post", subpath="test",
content_type="application/text",
After Change
def test_endpoint_config(loop):
with aioresponses() as mocked:
endpoint = EndpointConfig(
"https://example.com/",
params={"A": "B"},
headers={"X-Powered-By": "Rasa"},
basic_auth={"username": "user",
"password": "pass"},
token="mytoken",
token_name="letoken",
store_type="redis",
port=6379,
db=0,
password="password",
timeout=30000
)
mocked.post("https://example.com/test?A=B&P=1&letoken=mytoken",
payload={"ok": True},
repeat=True,
status=200)
loop.run_until_complete(
endpoint.request("post", subpath="test",
content_type="application/text",
json={"c": "d"},
params={"P": "1"}))
r = latest_request(mocked, "post",
"https://example.com/test?A=B&P=1&letoken=mytoken")
assert r
assert json_of_latest_request(r) == {"c": "d"}
assert r[-1].kwargs.get("params", {}).get("A") == "B"
assert r[-1].kwargs.get("params", {}).get("P") == "1"
assert r[-1].kwargs.get("params", {}).get("letoken") == "mytoken"
// unfortunately, the mock library won"t report any headers stored on
// the session object, so we need to verify them separately
s = loop.run_until_complete(endpoint.session())
assert s._default_headers.get("X-Powered-By") == "Rasa"
assert s._default_auth.login == "user"
assert s._default_auth.password == "pass"
os.environ["USER_NAME"] = "user"
os.environ["PASS"] = "pass"
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: RasaHQ/rasa
Commit Name: 87826c4ccb971911752adbc4bdac8d3e7c28989e
Time: 2019-01-21
Author: tom@rasa.com
File Name: tests/test_utils.py
Class Name:
Method Name: test_endpoint_config
Project Name: RasaHQ/rasa
Commit Name: 87826c4ccb971911752adbc4bdac8d3e7c28989e
Time: 2019-01-21
Author: tom@rasa.com
File Name: tests/test_actions.py
Class Name:
Method Name: test_remote_action_endpoint_responds_500
Project Name: RasaHQ/rasa
Commit Name: 87826c4ccb971911752adbc4bdac8d3e7c28989e
Time: 2019-01-21
Author: tom@rasa.com
File Name: tests/test_actions.py
Class Name:
Method Name: test_remote_action_endpoint_responds_400