2323 equal_to ,
2424 has_entries ,
2525 has_entry ,
26+ has_items ,
2627 instance_of ,
2728 is_not ,
2829 matches_regexp )
29- from pprint import pformat
3030import itertools
3131import requests
3232import json
@@ -107,15 +107,16 @@ def RunTest( app, test, contents = None ):
107107 expect_errors = True
108108 )
109109
110- print ( f'completer response: { pformat ( response .json ) } ' )
111-
112110 assert_that ( response .status_code ,
113111 equal_to ( test [ 'expect' ][ 'response' ] ) )
114112
115113 assert_that ( response .json , test [ 'expect' ][ 'data' ] )
116114 break
117115 except AssertionError :
118116 if time .time () > expiry :
117+ print ( 'completer response: '
118+ f'{ json .dumps ( response .json , indent = 2 ) } ' )
119+
119120 raise
120121
121122 time .sleep ( 0.25 )
@@ -1088,6 +1089,10 @@ def test_Subcommands_FixIt_SingleDiag_MultipleOption_Insertion( self, app ):
10881089 LocationMatcher ( filepath , 25 , 5 ) ),
10891090 ),
10901091 } ),
1092+ has_entries ( {
1093+ 'kind' : 'quickassist' ,
1094+ 'text' : "Add Javadoc for 'Wimble'"
1095+ } ),
10911096 )
10921097 } )
10931098
@@ -1146,6 +1151,9 @@ def test_Subcommands_FixIt_SingleDiag_SingleOption_Modify( self, app ):
11461151 LocationMatcher ( filepath , 25 , 5 ) ),
11471152 ),
11481153 } ),
1154+ has_entries ( {
1155+ 'text' : "Add Javadoc for 'getWidget'"
1156+ } ),
11491157 )
11501158 } )
11511159
@@ -1178,21 +1186,42 @@ def test_Subcommands_FixIt_SingleDiag_MultiOption_Delete( self, app ):
11781186 # FixIt (and nonetheless, the previous tests ensure that we correctly
11791187 # populate the chunks list; the contents all come from jdt.ls)
11801188 has_entries ( {
1181- 'text' : "Create getter and setter for 'testString' " ,
1189+ 'text' : "Organize imports " ,
11821190 'chunks' : instance_of ( list )
11831191 } ),
11841192 has_entries ( {
1185- 'text' : "Organize imports " ,
1193+ 'text' : "Generate Getter and Setter for 'testString' " ,
11861194 'chunks' : instance_of ( list )
11871195 } ),
11881196 has_entries ( {
11891197 'text' : "Generate Getters and Setters" ,
11901198 'chunks' : instance_of ( list )
11911199 } ),
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+ } ),
11921216 has_entries ( {
11931217 'text' : 'Change modifiers to final where possible' ,
11941218 'chunks' : instance_of ( list )
11951219 } ),
1220+ has_entries ( {
1221+ 'kind' : 'quickassist' ,
1222+ 'text' : "Add Javadoc for 'testString'" ,
1223+ 'chunks' : instance_of ( list )
1224+ } ),
11961225 )
11971226 } )
11981227
@@ -1271,6 +1300,10 @@ def test_Subcommands_FixIt_MultipleDiags( self, app ):
12711300 'text' : 'Change modifiers to final where possible' ,
12721301 'chunks' : instance_of ( list ),
12731302 } ),
1303+ has_entries ( {
1304+ 'text' : "Add Javadoc for 'getWidget'" ,
1305+ 'chunks' : instance_of ( list ),
1306+ } ),
12741307 ]
12751308
12761309 FIXITS = {
@@ -1395,6 +1428,10 @@ def test_Subcommands_FixIt_Range( self, app ):
13951428 'text' : 'Change modifiers to final where possible' ,
13961429 'chunks' : instance_of ( list ),
13971430 } ),
1431+ has_entries ( {
1432+ 'text' : "Add Javadoc for 'launch'" ,
1433+ 'chunks' : instance_of ( list ),
1434+ } ),
13981435 )
13991436 } )
14001437 }
@@ -1459,10 +1496,19 @@ def test_Subcommands_FixIt_Unicode( self, app ):
14591496 'text' : 'Change modifiers to final where possible' ,
14601497 'chunks' : instance_of ( list ),
14611498 } ),
1499+ has_entries ( {
1500+ 'text' : "Generate Getters" ,
1501+ } ),
1502+ has_entries ( {
1503+ 'text' : "Generate Setters" ,
1504+ } ),
14621505 has_entries ( {
14631506 'text' : "Generate Getters and Setters" ,
14641507 'chunks' : instance_of ( list ),
14651508 } ),
1509+ has_entries ( {
1510+ 'text' : "Add Javadoc for 'DoWhatever'"
1511+ } ),
14661512 )
14671513 } )
14681514
@@ -1524,6 +1570,9 @@ def test_Subcommands_FixIt_InvalidURI( self, app ):
15241570 LocationMatcher ( '' , 32 , 4 ) ),
15251571 ),
15261572 } ),
1573+ has_entries ( {
1574+ 'text' : "Add Javadoc for 'getWidget'"
1575+ } ),
15271576 )
15281577 } )
15291578
@@ -1637,6 +1686,9 @@ def test_Subcommands_Format_WholeFile_Spaces( self, app ):
16371686 ChunkMatcher ( '\n ' ,
16381687 LocationMatcher ( TEST_JAVA , 24 , 27 ),
16391688 LocationMatcher ( TEST_JAVA , 25 , 3 ) ),
1689+ ChunkMatcher ( '\n ' ,
1690+ LocationMatcher ( TEST_JAVA , 26 , 2 ),
1691+ LocationMatcher ( TEST_JAVA , 28 , 1 ) ),
16401692 )
16411693 } ) )
16421694 } )
@@ -1723,6 +1775,9 @@ def test_Subcommands_Format_WholeFile_Tabs( self, app ):
17231775 ChunkMatcher ( '\n \t ' ,
17241776 LocationMatcher ( TEST_JAVA , 24 , 27 ),
17251777 LocationMatcher ( TEST_JAVA , 25 , 3 ) ),
1778+ ChunkMatcher ( '\n ' ,
1779+ LocationMatcher ( TEST_JAVA , 26 , 2 ),
1780+ LocationMatcher ( TEST_JAVA , 28 , 1 ) ),
17261781 )
17271782 } ) )
17281783 } )
@@ -2116,13 +2171,9 @@ def test_Subcommands_IndexOutOfRange( self, app ):
21162171 'filepath' : TEST_JAVA ,
21172172 },
21182173 '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 )
21262177 }
21272178 } )
21282179
@@ -2162,8 +2213,8 @@ def test_Subcommands_DifferentFileTypesUpdate( self, app ):
21622213 'description' : 'Request error handles the error' ,
21632214 'request' : {
21642215 'command' : 'FixIt' ,
2165- 'line_num' : 99 ,
2166- 'column_num' : 99 ,
2216+ 'line_num' : 27 ,
2217+ 'column_num' : 1 ,
21672218 'filepath' : TEST_JAVA ,
21682219 'file_data' : {
21692220 '!/bin/sh' : {
@@ -2177,21 +2228,23 @@ def test_Subcommands_DifferentFileTypesUpdate( self, app ):
21772228 TESTLAUNCHER_JAVA : {
21782229 'filetypes' : [ 'some' , 'java' , 'junk' , 'also' ],
21792230 'contents' : ReadFile ( TESTLAUNCHER_JAVA ),
2180- },
2181- '!/usr/bin/sh' : {
2182- 'filetypes' : [ 'java' ],
2183- 'contents' : '\n ' ,
2184- },
2231+ }
21852232 }
21862233 },
21872234 'expect' : {
21882235 '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+ ),
21952248 }
21962249 } )
21972250
0 commit comments