23
23
equal_to ,
24
24
has_entries ,
25
25
has_entry ,
26
+ has_items ,
26
27
instance_of ,
27
28
is_not ,
28
29
matches_regexp )
29
- from pprint import pformat
30
30
import itertools
31
31
import requests
32
32
import json
@@ -107,15 +107,16 @@ def RunTest( app, test, contents = None ):
107
107
expect_errors = True
108
108
)
109
109
110
- print ( f'completer response: { pformat ( response .json ) } ' )
111
-
112
110
assert_that ( response .status_code ,
113
111
equal_to ( test [ 'expect' ][ 'response' ] ) )
114
112
115
113
assert_that ( response .json , test [ 'expect' ][ 'data' ] )
116
114
break
117
115
except AssertionError :
118
116
if time .time () > expiry :
117
+ print ( 'completer response: '
118
+ f'{ json .dumps ( response .json , indent = 2 ) } ' )
119
+
119
120
raise
120
121
121
122
time .sleep ( 0.25 )
@@ -1088,6 +1089,10 @@ def test_Subcommands_FixIt_SingleDiag_MultipleOption_Insertion( self, app ):
1088
1089
LocationMatcher ( filepath , 25 , 5 ) ),
1089
1090
),
1090
1091
} ),
1092
+ has_entries ( {
1093
+ 'kind' : 'quickassist' ,
1094
+ 'text' : "Add Javadoc for 'Wimble'"
1095
+ } ),
1091
1096
)
1092
1097
} )
1093
1098
@@ -1146,6 +1151,9 @@ def test_Subcommands_FixIt_SingleDiag_SingleOption_Modify( self, app ):
1146
1151
LocationMatcher ( filepath , 25 , 5 ) ),
1147
1152
),
1148
1153
} ),
1154
+ has_entries ( {
1155
+ 'text' : "Add Javadoc for 'getWidget'"
1156
+ } ),
1149
1157
)
1150
1158
} )
1151
1159
@@ -1178,21 +1186,42 @@ def test_Subcommands_FixIt_SingleDiag_MultiOption_Delete( self, app ):
1178
1186
# FixIt (and nonetheless, the previous tests ensure that we correctly
1179
1187
# populate the chunks list; the contents all come from jdt.ls)
1180
1188
has_entries ( {
1181
- 'text' : "Create getter and setter for 'testString' " ,
1189
+ 'text' : "Organize imports " ,
1182
1190
'chunks' : instance_of ( list )
1183
1191
} ),
1184
1192
has_entries ( {
1185
- 'text' : "Organize imports " ,
1193
+ 'text' : "Generate Getter and Setter for 'testString' " ,
1186
1194
'chunks' : instance_of ( list )
1187
1195
} ),
1188
1196
has_entries ( {
1189
1197
'text' : "Generate Getters and Setters" ,
1190
1198
'chunks' : instance_of ( list )
1191
1199
} ),
1200
+ has_entries ( {
1201
+ 'text' : "Generate Getters" ,
1202
+ 'chunks' : instance_of ( list )
1203
+ } ),
1204
+ has_entries ( {
1205
+ 'text' : "Generate Setters" ,
1206
+ 'chunks' : instance_of ( list )
1207
+ } ),
1208
+ has_entries ( {
1209
+ 'text' : "Generate Getter for 'testString'" ,
1210
+ 'chunks' : instance_of ( list )
1211
+ } ),
1212
+ has_entries ( {
1213
+ 'text' : "Generate Setter for 'testString'" ,
1214
+ 'chunks' : instance_of ( list )
1215
+ } ),
1192
1216
has_entries ( {
1193
1217
'text' : 'Change modifiers to final where possible' ,
1194
1218
'chunks' : instance_of ( list )
1195
1219
} ),
1220
+ has_entries ( {
1221
+ 'kind' : 'quickassist' ,
1222
+ 'text' : "Add Javadoc for 'testString'" ,
1223
+ 'chunks' : instance_of ( list )
1224
+ } ),
1196
1225
)
1197
1226
} )
1198
1227
@@ -1271,6 +1300,10 @@ def test_Subcommands_FixIt_MultipleDiags( self, app ):
1271
1300
'text' : 'Change modifiers to final where possible' ,
1272
1301
'chunks' : instance_of ( list ),
1273
1302
} ),
1303
+ has_entries ( {
1304
+ 'text' : "Add Javadoc for 'getWidget'" ,
1305
+ 'chunks' : instance_of ( list ),
1306
+ } ),
1274
1307
]
1275
1308
1276
1309
FIXITS = {
@@ -1395,6 +1428,10 @@ def test_Subcommands_FixIt_Range( self, app ):
1395
1428
'text' : 'Change modifiers to final where possible' ,
1396
1429
'chunks' : instance_of ( list ),
1397
1430
} ),
1431
+ has_entries ( {
1432
+ 'text' : "Add Javadoc for 'launch'" ,
1433
+ 'chunks' : instance_of ( list ),
1434
+ } ),
1398
1435
)
1399
1436
} )
1400
1437
}
@@ -1459,10 +1496,19 @@ def test_Subcommands_FixIt_Unicode( self, app ):
1459
1496
'text' : 'Change modifiers to final where possible' ,
1460
1497
'chunks' : instance_of ( list ),
1461
1498
} ),
1499
+ has_entries ( {
1500
+ 'text' : "Generate Getters" ,
1501
+ } ),
1502
+ has_entries ( {
1503
+ 'text' : "Generate Setters" ,
1504
+ } ),
1462
1505
has_entries ( {
1463
1506
'text' : "Generate Getters and Setters" ,
1464
1507
'chunks' : instance_of ( list ),
1465
1508
} ),
1509
+ has_entries ( {
1510
+ 'text' : "Add Javadoc for 'DoWhatever'"
1511
+ } ),
1466
1512
)
1467
1513
} )
1468
1514
@@ -1524,6 +1570,9 @@ def test_Subcommands_FixIt_InvalidURI( self, app ):
1524
1570
LocationMatcher ( '' , 32 , 4 ) ),
1525
1571
),
1526
1572
} ),
1573
+ has_entries ( {
1574
+ 'text' : "Add Javadoc for 'getWidget'"
1575
+ } ),
1527
1576
)
1528
1577
} )
1529
1578
@@ -1637,6 +1686,9 @@ def test_Subcommands_Format_WholeFile_Spaces( self, app ):
1637
1686
ChunkMatcher ( '\n ' ,
1638
1687
LocationMatcher ( TEST_JAVA , 24 , 27 ),
1639
1688
LocationMatcher ( TEST_JAVA , 25 , 3 ) ),
1689
+ ChunkMatcher ( '\n ' ,
1690
+ LocationMatcher ( TEST_JAVA , 26 , 2 ),
1691
+ LocationMatcher ( TEST_JAVA , 28 , 1 ) ),
1640
1692
)
1641
1693
} ) )
1642
1694
} )
@@ -1723,6 +1775,9 @@ def test_Subcommands_Format_WholeFile_Tabs( self, app ):
1723
1775
ChunkMatcher ( '\n \t ' ,
1724
1776
LocationMatcher ( TEST_JAVA , 24 , 27 ),
1725
1777
LocationMatcher ( TEST_JAVA , 25 , 3 ) ),
1778
+ ChunkMatcher ( '\n ' ,
1779
+ LocationMatcher ( TEST_JAVA , 26 , 2 ),
1780
+ LocationMatcher ( TEST_JAVA , 28 , 1 ) ),
1726
1781
)
1727
1782
} ) )
1728
1783
} )
@@ -2116,13 +2171,9 @@ def test_Subcommands_IndexOutOfRange( self, app ):
2116
2171
'filepath' : TEST_JAVA ,
2117
2172
},
2118
2173
'expect' : {
2119
- 'response' : requests .codes .ok ,
2120
- 'data' : has_entries ( { 'fixits' : contains_exactly (
2121
- has_entries ( { 'text' : 'Generate Getters and Setters' ,
2122
- 'chunks' : instance_of ( list ) } ),
2123
- has_entries ( { 'text' : 'Change modifiers to final where possible' ,
2124
- 'chunks' : instance_of ( list ) } ),
2125
- ) } ),
2174
+ # THough, now, jdt.ls just throws an Internal error.
2175
+ 'response' : requests .codes .internal_server_error ,
2176
+ 'data' : ErrorMatcher ( ResponseFailedException )
2126
2177
}
2127
2178
} )
2128
2179
@@ -2162,8 +2213,8 @@ def test_Subcommands_DifferentFileTypesUpdate( self, app ):
2162
2213
'description' : 'Request error handles the error' ,
2163
2214
'request' : {
2164
2215
'command' : 'FixIt' ,
2165
- 'line_num' : 99 ,
2166
- 'column_num' : 99 ,
2216
+ 'line_num' : 27 ,
2217
+ 'column_num' : 1 ,
2167
2218
'filepath' : TEST_JAVA ,
2168
2219
'file_data' : {
2169
2220
'!/bin/sh' : {
@@ -2177,21 +2228,23 @@ def test_Subcommands_DifferentFileTypesUpdate( self, app ):
2177
2228
TESTLAUNCHER_JAVA : {
2178
2229
'filetypes' : [ 'some' , 'java' , 'junk' , 'also' ],
2179
2230
'contents' : ReadFile ( TESTLAUNCHER_JAVA ),
2180
- },
2181
- '!/usr/bin/sh' : {
2182
- 'filetypes' : [ 'java' ],
2183
- 'contents' : '\n ' ,
2184
- },
2231
+ }
2185
2232
}
2186
2233
},
2187
2234
'expect' : {
2188
2235
'response' : requests .codes .ok ,
2189
- 'data' : has_entries ( { 'fixits' : contains_exactly (
2190
- has_entries ( { 'text' : 'Generate Getters and Setters' ,
2191
- 'chunks' : instance_of ( list ) } ),
2192
- has_entries ( { 'text' : 'Change modifiers to final where possible' ,
2193
- 'chunks' : instance_of ( list ) } ),
2194
- ) } ),
2236
+ 'data' : has_entries (
2237
+ {
2238
+ 'fixits' : has_items (
2239
+ has_entries ( {
2240
+ 'text' : 'Generate Getters and Setters' ,
2241
+ 'chunks' : instance_of ( list ) } ),
2242
+ has_entries ( {
2243
+ 'text' : 'Change modifiers to final where possible' ,
2244
+ 'chunks' : instance_of ( list ) } )
2245
+ )
2246
+ }
2247
+ ),
2195
2248
}
2196
2249
} )
2197
2250
0 commit comments