Skip to content

Commit

Permalink
Attempt to fix C# tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bstaletic committed Aug 12, 2024
1 parent 1305b9b commit 3952305
Showing 1 changed file with 7 additions and 157 deletions.
164 changes: 7 additions & 157 deletions ycmd/tests/cs/subcommands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def test_Subcommands_GoToSymbol( self, app ):
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 44, 15 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 49, 15 ) ) ),
( 'asd', ErrorMatcher( RuntimeError, 'No symbols found' ) )
( 'asd', ErrorMatcher( RuntimeError, 'Symbol not found' ) )
]:
with self.subTest( identifier = identifier, expected = expected ):
filepath = PathToTestFile( 'testy', 'GotoTestCase.cs' )
Expand Down Expand Up @@ -371,7 +371,7 @@ def test_Subcommands_GoToImplementation_NoImplementation( self, app ):
goto_data,
expect_errors = True ).json
assert_that( response, ErrorMatcher( RuntimeError,
'No implementations found' ) )
'Cannot jump to location' ) )


@SharedYcmd
Expand All @@ -393,69 +393,7 @@ def test_Subcommands_CsCompleter_InvalidLocation( self, app ):
goto_data,
expect_errors = True ).json
assert_that( response, ErrorMatcher( RuntimeError,
"Can't jump to implementation" ) )


@SharedYcmd
def test_Subcommands_GoToImplementationElseDeclaration_NoImplementation(
self, app ):
filepath = PathToTestFile( 'testy', 'GotoTestCase.cs' )
contents = ReadFile( filepath )

goto_data = BuildRequest(
completer_target = 'filetype_default',
command_arguments = [ 'GoToImplementationElseDeclaration' ],
line_num = 18,
column_num = 13,
contents = contents,
filetype = 'cs',
filepath = filepath
)

response = app.post_json( '/run_completer_command', goto_data ).json
assert_that( response, LocationMatcher( filepath, 36, 8 ) )


@SharedYcmd
def test_Subcommands_GoToImplementationElseDeclaration_SingleImplementation(
self, app ):
filepath = PathToTestFile( 'testy', 'GotoTestCase.cs' )
contents = ReadFile( filepath )

goto_data = BuildRequest(
completer_target = 'filetype_default',
command_arguments = [ 'GoToImplementationElseDeclaration' ],
line_num = 14,
column_num = 13,
contents = contents,
filetype = 'cs',
filepath = filepath
)

response = app.post_json( '/run_completer_command', goto_data ).json
assert_that( response, LocationMatcher( filepath, 31, 15 ) )


@SharedYcmd
def test_Subcommands_GoToImplementationElseDeclaration_Multiple(
self, app ):
filepath = PathToTestFile( 'testy', 'GotoTestCase.cs' )
contents = ReadFile( filepath )

goto_data = BuildRequest(
completer_target = 'filetype_default',
command_arguments = [ 'GoToImplementationElseDeclaration' ],
line_num = 22,
column_num = 13,
contents = contents,
filetype = 'cs',
filepath = filepath
)

response = app.post_json( '/run_completer_command', goto_data ).json
assert_that( response,
contains_exactly( LocationMatcher( filepath, 44, 15 ),
LocationMatcher( filepath, 49, 15 ) ) )
'Cannot jump to location' ) )


@SharedYcmd
Expand Down Expand Up @@ -558,7 +496,7 @@ def test_Subcommands_GetType_EmptyMessage( self, app ):
gettype_data,
expect_errors = True ).json
assert_that( response, ErrorMatcher( RuntimeError,
'No type info available.' ) )
'No type found.' ) )


@SharedYcmd
Expand Down Expand Up @@ -592,7 +530,8 @@ def test_Subcommands_GetType_VariableUsage( self, app ):
filepath = filepath )

response = app.post_json( '/run_completer_command', gettype_data ).json
assert_that( response, has_entry( 'message', 'string str' ) )
assert_that( response, has_entry( 'message',
'(local variable) string str' ) )


@SharedYcmd
Expand All @@ -610,67 +549,7 @@ def test_Subcommands_GetType_DocsIgnored( self, app ):

response = app.post_json( '/run_completer_command', gettype_data ).json
assert_that( response, has_entry(
'message', 'int GetTypeTestCase.an_int_with_docs' ) )


@SharedYcmd
def test_Subcommands_GetDoc_Invalid( self, app ):
filepath = PathToTestFile( 'testy', 'GetDocTestCase.cs' )
contents = ReadFile( filepath )

getdoc_data = BuildRequest( completer_target = 'filetype_default',
command_arguments = [ 'GetDoc' ],
line_num = 1,
column_num = 1,
contents = contents,
filetype = 'cs',
filepath = filepath )

response = app.post_json( '/run_completer_command',
getdoc_data,
expect_errors = True ).json
assert_that( response, ErrorMatcher( RuntimeError,
'No documentation available.' ) )


@SharedYcmd
def test_Subcommands_GetDoc_Variable( self, app ):
filepath = PathToTestFile( 'testy', 'GetDocTestCase.cs' )
contents = ReadFile( filepath )

getdoc_data = BuildRequest( completer_target = 'filetype_default',
command_arguments = [ 'GetDoc' ],
line_num = 13,
column_num = 28,
contents = contents,
filetype = 'cs',
filepath = filepath )

response = app.post_json( '/run_completer_command', getdoc_data ).json
assert_that( response,
has_entry( 'detailed_info',
'int GetDocTestCase.an_int\n'
'an integer, or something' ) )


@SharedYcmd
def test_Subcommands_GetDoc_Function( self, app ):
filepath = PathToTestFile( 'testy', 'GetDocTestCase.cs' )
contents = ReadFile( filepath )

getdoc_data = BuildRequest( completer_target = 'filetype_default',
command_arguments = [ 'GetDoc' ],
line_num = 33,
column_num = 27,
contents = contents,
filetype = 'cs',
filepath = filepath )

response = app.post_json( '/run_completer_command', getdoc_data ).json
assert_that( response, has_entry( 'detailed_info',
'int GetDocTestCase.DoATest()\n'
'Very important method.\n\nWith multiple lines of '
'commentary\nAnd Format-\n-ting' ) )
'message', '(field) int GetTypeTestCase.an_int_with_docs' ) )


@IsolatedYcmd()
Expand Down Expand Up @@ -850,35 +729,6 @@ def test_Subcommands_RangeFormat_Works( self, app ):
) } ) ) } ) )


@SharedYcmd
def test_Subcommands_OrganizeImports( self, app ):
filepath = PathToTestFile( 'testy', 'ImportTest.cs' )
request = BuildRequest( command_arguments = [ 'OrganizeImports' ],
line_num = 11,
column_num = 2,
contents = ReadFile( filepath ),
filetype = 'cs',
filepath = filepath )

response = app.post_json( '/run_completer_command', request ).json
print( 'completer response = ', response )
assert_that( response, has_entries( {
'fixits': contains_exactly( has_entries( {
'location': LocationMatcher( filepath, 11, 2 ),
'chunks': contains_exactly(
ChunkMatcher(
' ',
LocationMatcher( filepath, 5, 1 ),
LocationMatcher( filepath, 5, 2 ),
),
ChunkMatcher(
'',
LocationMatcher( filepath, 1, 1 ),
LocationMatcher( filepath, 3, 1 ),
)
) } ) ) } ) )


@SharedYcmd
def test_Subcommands_GoToDocumentOutline( self, app ):

Expand Down

0 comments on commit 3952305

Please sign in to comment.