87826c4ccb971911752adbc4bdac8d3e7c28989e,tests/test_utils.py,,test_endpoint_config,#Any#,84

Before Change


    assert json.loads(str(r.body.decode("utf-8"))) == {"c": "d"}
    assert r.headers.get("X-Powered-By") == "Rasa"
    assert r.headers.get("Authorization") == "Basic dXNlcjpwYXNz"
    assert r.querystring.get("A") == ["B"]
    assert r.querystring.get("P") == ["1"]
    assert r.querystring.get("letoken") == ["mytoken"]

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"

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

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_channels.py
Class Name:
Method Name: test_callback_calls_endpoint


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_runs