Skip to content

Commit

Permalink
Add Load tests for extra_conf_store module
Browse files Browse the repository at this point in the history
Check that the extra conf file is not reloaded, whether the force
parameter is given or not.
micbou committed Nov 18, 2016
1 parent a51f9ac commit 93a9994
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion ycmd/tests/extra_conf_store_test.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@
import inspect
from mock import patch

from hamcrest import assert_that, calling, equal_to, has_length, none, raises
from hamcrest import ( assert_that, calling, equal_to, has_length, none, raises,
same_instance )
from ycmd import extra_conf_store
from ycmd.responses import UnknownExtraConf
from ycmd.tests import PathToTestFile
@@ -139,3 +140,29 @@ def CallGlobalExtraConfMethod_CatchExceptionFromExtraConf_test( self,
logger.exception.assert_called_with( 'Error occurred while '
'loading global extra conf '
'{0}'.format( extra_conf_file ) )


def Load_DoNotReloadExtraConf_NoForce_test( self ):
extra_conf_file = PathToTestFile( 'extra_conf', 'project',
'.ycm_extra_conf.py' )
with patch( 'ycmd.extra_conf_store._ShouldLoad', return_value = True ):
module = extra_conf_store.Load( extra_conf_file )
assert_that( inspect.ismodule( module ) )
assert_that( inspect.getfile( module ), equal_to( extra_conf_file ) )
assert_that(
extra_conf_store.Load( extra_conf_file ),
same_instance( module )
)


def Load_DoNotReloadExtraConf_ForceEqualsTrue_test( self ):
extra_conf_file = PathToTestFile( 'extra_conf', 'project',
'.ycm_extra_conf.py' )
with patch( 'ycmd.extra_conf_store._ShouldLoad', return_value = True ):
module = extra_conf_store.Load( extra_conf_file )
assert_that( inspect.ismodule( module ) )
assert_that( inspect.getfile( module ), equal_to( extra_conf_file ) )
assert_that(
extra_conf_store.Load( extra_conf_file, force = True ),
same_instance( module )
)

0 comments on commit 93a9994

Please sign in to comment.