[{'Text': 'def test_list_operators():\n    """list_operators returns all operators sorted by name."""\n    from bson import ObjectId\n\n    import point_topic_mcp.tools.gbs_tools as gbs\n\n    if not hasattr(gbs, "list_operators"):\n        pytest.skip("GBS tools not loaded (PT_RESEARCH_DATABASE_URI not set)")\n\n    op_id_a = ObjectId()\n    op_id_b = ObjectId()\n    op_id_c = ObjectId()\n    # Intentionally unsorted input to verify sorting is applied\n    mock_ops = [\n        {"_id": {"$oid": str(op_id_b)}, "name": "Zebra", "country": "UK", "technologies": ["FTTP"]},\n        {"_id": {"$oid": str(op_id_a)}, "name": "Alpha", "country": "UK", "technologies": ["FTTP"]},\n        {"_id": {"$oid": str(op_id_c)}, "name": "Beta", "country": "UK", "technologies": ["FTTP"]},\n    ]\n    \n    with patch("point_topic_mcp.core.mongodb_utils.find_operators", return_value=mock_ops):\n        # Test 1: basic call, should be sorted\n        result = gbs.list_operators()\n        assert "Operators:" in result\n        assert "Alpha" in result\n        assert "Beta" in result\n        assert "Zebra" in result\n        # Check ordering: Alpha should appear before Beta, Beta before Zebra\n        alpha_pos = result.find("Alpha")\n        beta_pos = result.find("Beta")\n        zebra_pos = result.find("Zebra")\n        assert alpha_pos < beta_pos < zebra_pos, "Operators should be sorted alphabetically"\n        \n        # Test 2: with country filter\n        result_filtered = gbs.list_operators(country="UK")\n        assert "(country filter: \'UK\', 3 match(es))" in result_filtered\n\n\ndef test_get_gbs_status_operator_not_found():\n    """get_gbs_status returns error when operator doesn\'t exist."""\n    import point_topic_mcp.tools.gbs_tools as gbs\n\n    if not hasattr(gbs, "get_gbs_status"):\n        pytest.skip("GBS tools not loaded (PT_RESEARCH_DATABASE_URI not set)")\n\n    with patch("point_topic_mcp.core.mongodb_utils.find_one_operator", return_value=None):\n        result = gbs.get_gbs_status("UK", "NoSuchOperator", "2025Q1")\n        assert "Operator not found" in result\n\n\ndef test_get_gbs_status_success():\n    """get_gbs_status returns status with operator_id, gaps grouped by type, staleness."""\n    from bson import ObjectId\n\n    import point_topic_mcp.tools.gbs_tools as gbs\n\n    if not hasattr(gbs, "get_gbs_status"):\n        pytest.skip("GBS tools not loaded (PT_RESEARCH_DATABASE_URI not set)")\n\n    op_id = ObjectId()\n    mock_op = {"_id": {"$oid": str(op_id)}, "name": "BT", "country": "UK", "technologies": ["FTTP", "FTTC"]}\n    mock_stats = [{"type": "broadband", "tech": "FTTP", "channel": "Infrastructure", "domain": "Residential", "state": 1}]\n    mock_gv = {"isCurrent": True, "currentStatsPeriod": "2025Q1"}\n    with (\n        patch("point_topic_mcp.core.mongodb_utils.find_one_operator", return_value=mock_op),\n        patch("point_topic_mcp.core.mongodb_utils.find_statistics", return_value=mock_stats),\n        patch("point_topic_mcp.core.mongodb_utils.find_global_variables_current", return_value=mock_gv),\n    ):\n        result = gbs.get_gbs_status("UK", "BT", "2025Q1")\n        assert "GBS status: BT (UK)" in result\n        assert "operator_id: " + str(op_id) in result\n        assert "technologies: FTTP, FTTC" in result\n        assert "Existing: 1 records" in result\n        assert "by type: broadband: 1" in result\n        assert "by state: pending: 1" in result\n        assert "Staleness: current" in result\n        assert "broadband (" in result\n        assert "mobile (" in result\n        assert "iptv (" in result\n\n    # Test staleness with older period\n    mock_gv_ahead = {"isCurrent": True, "currentStatsPeriod": "2025Q3"}\n    with (\n        patch("point_topic_mcp.core.mongodb_utils.find_one_operator", return_value=mock_op),\n        patch("point_topic_mcp.core.mongodb_utils.find_statistics", return_value=[]),\n        patch("point_topic_mcp.core.mongodb_utils.find_global_variables_current", return_value=mock_gv_ahead),\n    ):\n        result2 = gbs.get_gbs_status("UK", "BT", "2025Q1")\n        assert "2 quarters behind current (2025Q3)" in result2\n\n\ndef test_add_statistic_validation():\n    """add_statistic returns errors for invalid inputs."""\n    import point_topic_mcp.tools.gbs_tools as gbs\n\n    if not hasattr(gbs, "add_statistic"):\n        pytest.skip("GBS tools not loaded")\n'}]