@@ -1041,183 +1041,6 @@ def test_list_grants(self, mock_request):
10411041 assert grants .results [0 ].opportunity_number == "OPP-123"
10421042
10431043
1044- # ============================================================================
1045- # Vehicles (Awards) Endpoint Tests
1046- # ============================================================================
1047-
1048-
1049- class TestVehiclesEndpoints :
1050- """Test Vehicles endpoints"""
1051-
1052- @patch ("tango.client.httpx.Client.request" )
1053- def test_list_vehicles_uses_default_shape_and_search (self , mock_request ):
1054- mock_response = Mock ()
1055- mock_response .is_success = True
1056- mock_response .content = b'{"count": 1}'
1057- mock_response .json .return_value = {
1058- "count" : 1 ,
1059- "next" : None ,
1060- "previous" : None ,
1061- "results" : [
1062- {
1063- "uuid" : "00000000-0000-0000-0000-000000000001" ,
1064- "solicitation_identifier" : "47QSWA20D0001" ,
1065- "organization_id" : "00000000-0000-0000-0000-000000000099" ,
1066- "awardee_count" : 12 ,
1067- "order_count" : 345 ,
1068- "vehicle_obligations" : "123.45" ,
1069- "vehicle_contracts_value" : "999.99" ,
1070- "solicitation_title" : "GSA MAS" ,
1071- "solicitation_date" : "2024-01-15" ,
1072- }
1073- ],
1074- }
1075- mock_request .return_value = mock_response
1076-
1077- client = TangoClient (api_key = "test-key" )
1078- vehicles = client .list_vehicles (search = "GSA" , limit = 10 )
1079-
1080- call_args = mock_request .call_args
1081- params = call_args [1 ]["params" ]
1082- assert params ["shape" ] == ShapeConfig .VEHICLES_MINIMAL
1083- assert params ["search" ] == "GSA"
1084-
1085- assert vehicles .count == 1
1086- v = vehicles .results [0 ]
1087- assert v ["solicitation_identifier" ] == "47QSWA20D0001"
1088- assert v ["vehicle_obligations" ] == Decimal ("123.45" )
1089- assert isinstance (v ["solicitation_date" ], date )
1090-
1091- @patch ("tango.client.httpx.Client.request" )
1092- def test_get_vehicle_supports_joiner_and_flat_lists (self , mock_request ):
1093- mock_response = Mock ()
1094- mock_response .is_success = True
1095- mock_response .content = b'{"uuid": "00000000-0000-0000-0000-000000000001"}'
1096- mock_response .json .return_value = {
1097- "uuid" : "00000000-0000-0000-0000-000000000001" ,
1098- "opportunity__title" : "Test Opportunity" ,
1099- }
1100- mock_request .return_value = mock_response
1101-
1102- client = TangoClient (api_key = "test-key" )
1103- vehicle = client .get_vehicle (
1104- "00000000-0000-0000-0000-000000000001" ,
1105- shape = "uuid,opportunity(title)" ,
1106- flat = True ,
1107- flat_lists = True ,
1108- joiner = "__" ,
1109- )
1110-
1111- call_args = mock_request .call_args
1112- params = call_args [1 ]["params" ]
1113- assert params ["shape" ] == "uuid,opportunity(title)"
1114- assert params ["flat" ] == "true"
1115- assert params ["flat_lists" ] == "true"
1116- assert params ["joiner" ] == "__"
1117-
1118- assert vehicle ["uuid" ] == "00000000-0000-0000-0000-000000000001"
1119- assert vehicle ["opportunity" ]["title" ] == "Test Opportunity"
1120-
1121- @patch ("tango.client.httpx.Client.request" )
1122- def test_list_vehicle_awardees_uses_default_shape (self , mock_request ):
1123- mock_response = Mock ()
1124- mock_response .is_success = True
1125- mock_response .content = b'{"count": 1}'
1126- mock_response .json .return_value = {
1127- "count" : 1 ,
1128- "next" : None ,
1129- "previous" : None ,
1130- "results" : [
1131- {
1132- "uuid" : "00000000-0000-0000-0000-000000000002" ,
1133- "key" : "IDV-KEY" ,
1134- "piid" : "47QSWA20D0001" ,
1135- "award_date" : "2024-01-01" ,
1136- "title" : "Acme Corp" ,
1137- "order_count" : 10 ,
1138- "idv_obligations" : "100.00" ,
1139- "idv_contracts_value" : "250.50" ,
1140- "recipient" : {"display_name" : "Acme Corp" , "uei" : "UEI123" },
1141- }
1142- ],
1143- }
1144- mock_request .return_value = mock_response
1145-
1146- client = TangoClient (api_key = "test-key" )
1147- awardees = client .list_vehicle_awardees ("00000000-0000-0000-0000-000000000001" , limit = 10 )
1148-
1149- call_args = mock_request .call_args
1150- params = call_args [1 ]["params" ]
1151- assert params ["shape" ] == ShapeConfig .VEHICLE_AWARDEES_MINIMAL
1152-
1153- assert awardees .count == 1
1154- a = awardees .results [0 ]
1155- assert a ["key" ] == "IDV-KEY"
1156- assert a ["idv_obligations" ] == Decimal ("100.00" )
1157- assert isinstance (a ["award_date" ], date )
1158- assert a ["recipient" ]["display_name" ] == "Acme Corp"
1159-
1160-
1161- class TestIDVEndpoints :
1162- """Test IDV endpoints wiring"""
1163-
1164- @patch ("tango.client.httpx.Client.request" )
1165- def test_list_idvs_uses_default_shape_and_keyset_params (self , mock_request ):
1166- mock_response = Mock ()
1167- mock_response .is_success = True
1168- mock_response .content = b'{"count": 1}'
1169- mock_response .json .return_value = {
1170- "count" : 1 ,
1171- "next" : "https://example.test/api/idvs/?cursor=next" ,
1172- "previous" : None ,
1173- "results" : [
1174- {
1175- "key" : "IDV-KEY" ,
1176- "piid" : "47QSWA20D0001" ,
1177- "award_date" : "2024-01-01" ,
1178- "recipient" : {"display_name" : "Acme Corp" , "uei" : "UEI123" },
1179- "description" : "Test IDV" ,
1180- "total_contract_value" : "1000.00" ,
1181- "obligated" : "10.00" ,
1182- "idv_type" : {"code" : "A" , "description" : "GWAC" },
1183- }
1184- ],
1185- }
1186- mock_request .return_value = mock_response
1187-
1188- client = TangoClient (api_key = "test-key" )
1189- resp = client .list_idvs (limit = 10 , cursor = "abc" , awarding_agency = "4700" )
1190-
1191- call_args = mock_request .call_args
1192- params = call_args [1 ]["params" ]
1193- assert params ["shape" ] == ShapeConfig .IDVS_MINIMAL
1194- assert params ["limit" ] == 10
1195- assert params ["cursor" ] == "abc"
1196- assert params ["awarding_agency" ] == "4700"
1197-
1198- assert resp .count == 1
1199- item = resp .results [0 ]
1200- assert item ["key" ] == "IDV-KEY"
1201- assert isinstance (item ["award_date" ], date )
1202- assert item ["obligated" ] == Decimal ("10.00" )
1203-
1204- @patch ("tango.client.httpx.Client.request" )
1205- def test_get_idv_uses_default_shape (self , mock_request ):
1206- mock_response = Mock ()
1207- mock_response .is_success = True
1208- mock_response .content = b'{"key": "IDV-KEY"}'
1209- mock_response .json .return_value = {"key" : "IDV-KEY" , "piid" : "47QSWA20D0001" }
1210- mock_request .return_value = mock_response
1211-
1212- client = TangoClient (api_key = "test-key" )
1213- idv = client .get_idv ("IDV-KEY" )
1214-
1215- call_args = mock_request .call_args
1216- params = call_args [1 ]["params" ]
1217- assert params ["shape" ] == ShapeConfig .IDVS_COMPREHENSIVE
1218- assert idv ["key" ] == "IDV-KEY"
1219-
1220-
12211044# ============================================================================
12221045# Parser Tests
12231046# ============================================================================
0 commit comments