def test_qm_user_reload():
    with mock.patch("umapi_client.connection.requests.Session.get") as mock_get:
        mock_get.side_effect = [MockResponse(200, {"result": "success",
                                                   "lastPage": False,
                                                   "users": [{"name": "n1", "type": "user"},
                                                             {"name": "n2", "type": "user"}]}),
                                MockResponse(200, {"result": "success",
                                                   "lastPage": True,
                                                   "users": [{"name": "n3", "type": "user"},
                                                             {"name": "n4", "type": "user"}]}),
                                MockResponse(200, {"result": "success",
                                                   "lastPage": False,
                                                   "users": [{"name": "n5", "type": "user"},
                                                             {"name": "n6", "type": "user"}]}),
                                MockResponse(200, {"result": "success",
                                                   "lastPage": True,
                                                   "users": [{"name": "n7", "type": "user"},
                                                             {"name": "n8", "type": "user"}]})]
        conn = Connection(**mock_connection_params)
        qm = QueryMultiple(conn, "user")
        assert list(qm) == [{"name": "n1", "type": "user"},
                            {"name": "n2", "type": "user"},
                            {"name": "n3", "type": "user"},
                            {"name": "n4", "type": "user"}]
        qm.reload()
        assert qm.all_results() == [{"name": "n5", "type": "user"},
                                    {"name": "n6", "type": "user"},
                                    {"name": "n7", "type": "user"},
                                    {"name": "n8", "type": "user"}]
def test_qm_usergroup_reload():
    with mock.patch("umapi_client.connection.requests.Session.get") as mock_get:
        mock_get.side_effect = [MockResponse(200,
                                             [{"name": "n1", "type": "user-group"},
                                              {"name": "n2", "type": "user-group"}],
                                             {"X-Total-Count": "4",
                                              "X-Page-Count": "2",
                                              "X-Current-Page": "1",
                                              "X-Page-Size:": "2"}),
                                MockResponse(200,
                                             [{"name": "n3", "type": "user-group"},
                                              {"name": "n4", "type": "user-group"}],
                                             {"X-Total-Count": "4",
                                              "X-Page-Count": "2",
                                              "X-Current-Page": "2",
                                              "X-Page-Size:": "2"}),
                                MockResponse(200,
                                             [{"name": "n5", "type": "user-group"},
                                              {"name": "n6", "type": "user-group"}],
                                             {"X-Total-Count": "4",
                                              "X-Page-Count": "2",
                                              "X-Current-Page": "1",
                                              "X-Page-Size:": "2"}),
                                MockResponse(200,
                                             [{"name": "n7", "type": "user-group"},
                                              {"name": "n8", "type": "user-group"}],
                                             {"X-Total-Count": "4",
                                              "X-Page-Count": "2",
                                              "X-Current-Page": "2",
                                              "X-Page-Size:": "2"})]
        conn = Connection(**mock_connection_params)
        qm = QueryMultiple(conn, "user-group")
        assert list(qm) == [{"name": "n1", "type": "user-group"},
                            {"name": "n2", "type": "user-group"},
                            {"name": "n3", "type": "user-group"},
                            {"name": "n4", "type": "user-group"}]
        qm.reload()
        assert qm.all_results() == [{"name": "n5", "type": "user-group"},
                                    {"name": "n6", "type": "user-group"},
                                    {"name": "n7", "type": "user-group"},
                                    {"name": "n8", "type": "user-group"}]