Skip to main content
Glama

Congress[.]gov MCP Server

by AshwinSundar
test_house_communication.py4.79 kB
import unittest import time from server import get_house_communication class TestHouseCommunicationAPI(unittest.TestCase): """Test the get_house_communication endpoint with real API calls""" def setUp(self): """Add a small delay between tests to be respectful to the API""" time.sleep(0.5) def test_get_house_communication_no_params(self): """Test get_house_communication with no parameters (list all communications)""" result = get_house_communication() self.assertIsInstance(result, dict) if "error" not in result: # Common possible response structures for house communications self.assertTrue("houseCommunications" in result or "communications" in result or "houseCommunication" in result) def test_get_house_communication_with_congress(self): """Test get_house_communication with congress parameter""" result = get_house_communication(congress=118) self.assertIsInstance(result, dict) if "error" not in result: self.assertTrue("houseCommunications" in result or "communications" in result or "houseCommunication" in result) def test_get_house_communication_with_congress_and_type(self): """Test get_house_communication with congress and communication_type parameters""" result = get_house_communication(congress=118, communication_type="ec") self.assertIsInstance(result, dict) if "error" not in result: self.assertTrue("houseCommunications" in result or "communications" in result or "houseCommunication" in result) def test_get_house_communication_with_pagination(self): """Test get_house_communication with offset and limit parameters""" result = get_house_communication(congress=118, offset=0, limit=5) self.assertIsInstance(result, dict) if "error" not in result: # Check for communication data comm_data = None for key in ["houseCommunications", "communications", "houseCommunication"]: if key in result: comm_data = result[key] break if comm_data is not None: self.assertIsInstance(comm_data, list) # Should have at most 5 communications self.assertLessEqual(len(comm_data), 5) def test_get_house_communication_with_small_limit(self): """Test get_house_communication with a small limit to get quick results""" result = get_house_communication(congress=118, limit=3) self.assertIsInstance(result, dict) if "error" not in result: # Check for communication data comm_data = None for key in ["houseCommunications", "communications", "houseCommunication"]: if key in result: comm_data = result[key] break if comm_data is not None: self.assertIsInstance(comm_data, list) # Should have at most 3 communications self.assertLessEqual(len(comm_data), 3) def test_get_house_communication_response_structure(self): """Test that API response has expected structure""" result = get_house_communication(congress=118, limit=1) self.assertIsInstance(result, dict) if "error" not in result: # Check for communication data comm_data = None for key in ["houseCommunications", "communications", "houseCommunication"]: if key in result: comm_data = result[key] break if comm_data is not None and len(comm_data) > 0: communication = comm_data[0] # Check for common communication fields possible_fields = ["congress", "type", "number", "communicationType"] has_comm_field = any(field in communication for field in possible_fields) self.assertTrue(has_comm_field, f"Communication missing expected fields. Available fields: {list(communication.keys())}") def test_get_house_communication_limit_enforcement(self): """Test that limit parameter works""" result = get_house_communication(congress=118, limit=2) self.assertIsInstance(result, dict) if "error" not in result: # Check for communication data comm_data = None for key in ["houseCommunications", "communications", "houseCommunication"]: if key in result: comm_data = result[key] break if comm_data is not None: self.assertLessEqual(len(comm_data), 2) if __name__ == '__main__': unittest.main()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AshwinSundar/congress_gov_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server