Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate infrastructure from actual tests
Move infrastructure used in shutdown tests to its own class. Since this is a client implementation, call it Client_test instead of Server_test. Create a new class Shutdown_test inheriting Client_test.
- Loading branch information
Showing
2 changed files
with
81 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright (C) 2015 ycmd contributors | ||
# | ||
# This file is part of ycmd. | ||
# | ||
# ycmd is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ycmd is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with ycmd. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from hamcrest import assert_that, greater_than, has_length | ||
from test_utils import BuildRequest | ||
from .client_test import Client_test | ||
|
||
|
||
class Shutdown_test( Client_test ): | ||
|
||
def FromHandlerWithNoSubserver_test( self ): | ||
self._Start() | ||
self._WaitUntilReady() | ||
|
||
response = self._PostRequest( 'shutdown' ) | ||
self._AssertResponse( response ) | ||
|
||
self._AssertServerAndSubserversShutDown() | ||
|
||
|
||
def FromHandlerWithSubserver_test( self ): | ||
self._Start() | ||
self._WaitUntilReady() | ||
|
||
response = self._PostRequest( | ||
'run_completer_command', | ||
BuildRequest( command_arguments = [ 'StartServer' ], | ||
filetype = 'javascript' ) | ||
) | ||
self._AssertResponse( response ) | ||
|
||
self._subservers = self._GetSubservers() | ||
assert_that( self._subservers, has_length( greater_than( 0 ) ) ) | ||
|
||
response = self._PostRequest( 'shutdown' ) | ||
self._AssertResponse( response ) | ||
|
||
self._AssertServerAndSubserversShutDown() | ||
|
||
|
||
def FromWatchdogWithNoSubserver_test( self ): | ||
self._Start( idle_suicide_seconds = 2, check_interval_seconds = 1 ) | ||
self._WaitUntilReady() | ||
|
||
self._AssertServerAndSubserversShutDown() | ||
|
||
|
||
def FromWatchdogWithSubserver_test( self ): | ||
self._Start( idle_suicide_seconds = 2, check_interval_seconds = 1 ) | ||
self._WaitUntilReady() | ||
|
||
response = self._PostRequest( | ||
'run_completer_command', | ||
BuildRequest( command_arguments = [ 'StartServer' ], | ||
filetype = 'javascript' ) | ||
) | ||
self._AssertResponse( response ) | ||
|
||
self._subservers = self._GetSubservers() | ||
assert_that( self._subservers, has_length( greater_than( 0 ) ) ) | ||
|
||
self._AssertServerAndSubserversShutDown() |