コード例 #1
0
def test_mock_proxy_get():
    with mock.patch("umapi_client.connection.requests.Session.get") as mock_get:
        mock_get.return_value = MockResponse(200, body=["test", "body"])
        with mock.patch("umapi_client.connection.os.getenv") as mock_getenv:
            mock_getenv.return_value = "proxy"
            conn = Connection(**mock_connection_params)
            conn.make_call("").json()
            mock_get.assert_called_with('http://test/', auth='N/A', timeout=120.0)
コード例 #2
0
def test_mock_playback_get():
    with mock.patch("umapi_client.connection.requests.Session.get") as mock_get:
        mock_get.return_value = MockResponse(200, body=["test", "body"])
        with mock.patch("umapi_client.connection.os.getenv") as mock_getenv:
            mock_getenv.return_value = "playback"
            conn = Connection(**mock_connection_params)
            conn.make_call("").json()
            assert mock_get.call_args[0][0] == 'http://test/'
            assert isinstance(mock_get.call_args[1]['auth'], Auth)
コード例 #3
0
def test_post_success_test_mode():
    with mock.patch("umapi_client.connection.requests.Session.post") as mock_post:
        mock_post.return_value = MockResponse(200, body=["test", "body"])
        conn = Connection(test_mode=True, **mock_connection_params)
        assert conn.make_call("", [3, 5]).json() == ["test", "body"]
コード例 #4
0
def test_get_success():
    with mock.patch("umapi_client.connection.requests.Session.get") as mock_get:
        mock_get.return_value = MockResponse(200, body=["test", "body"])
        conn = Connection(**mock_connection_params)
        assert conn.make_call("").json() == ["test", "body"]