fix: make pylint happy; fix test around continuum feature
This commit is contained in:
parent
d3213c5773
commit
bc5e7bb2f9
2 changed files with 27 additions and 25 deletions
|
|
@ -231,7 +231,7 @@ class InstallHandler(GenericHandler): # pylint: disable=too-many-public-methods
|
||||||
# continuum
|
# continuum
|
||||||
if self.wants_continuum is None:
|
if self.wants_continuum is None:
|
||||||
try:
|
try:
|
||||||
import wutta_continuum
|
import wutta_continuum # pylint: disable=import-outside-toplevel,unused-import
|
||||||
except ImportError:
|
except ImportError:
|
||||||
self.wants_continuum = False
|
self.wants_continuum = False
|
||||||
else:
|
else:
|
||||||
|
|
@ -258,10 +258,7 @@ class InstallHandler(GenericHandler): # pylint: disable=too-many-public-methods
|
||||||
"""
|
"""
|
||||||
# get db info/url
|
# get db info/url
|
||||||
dbinfo = self.get_dbinfo()
|
dbinfo = self.get_dbinfo()
|
||||||
if "db_url" in dbinfo:
|
db_url = dbinfo.get("db_url", self.make_db_url(dbinfo))
|
||||||
db_url = dbinfo["db_url"]
|
|
||||||
else:
|
|
||||||
db_url = self.make_db_url(dbinfo)
|
|
||||||
|
|
||||||
# test db connection
|
# test db connection
|
||||||
self.rprint("\n\ttesting db connection... ", end="")
|
self.rprint("\n\ttesting db connection... ", end="")
|
||||||
|
|
|
||||||
|
|
@ -86,37 +86,42 @@ class TestInstallHandler(ConfigTestCase):
|
||||||
|
|
||||||
# should prompt for continuum by default
|
# should prompt for continuum by default
|
||||||
handler = self.make_handler()
|
handler = self.make_handler()
|
||||||
with patch.object(handler, "prompt_bool") as prompt_bool:
|
with patch("builtins.__import__"): # nb. pretend import is ok
|
||||||
prompt_bool.return_value = True
|
|
||||||
context = handler.prompt_user_for_context()
|
|
||||||
prompt_bool.assert_called_once_with(
|
|
||||||
"use continuum for data versioning?", default=False
|
|
||||||
)
|
|
||||||
self.assertEqual(context, {"db_url": db_url, "wants_continuum": True})
|
|
||||||
|
|
||||||
# should not prompt if continuum flag already true
|
|
||||||
handler = self.make_handler()
|
|
||||||
with patch.object(handler, "wants_continuum", new=True):
|
|
||||||
with patch.object(handler, "prompt_bool") as prompt_bool:
|
with patch.object(handler, "prompt_bool") as prompt_bool:
|
||||||
|
prompt_bool.return_value = True
|
||||||
context = handler.prompt_user_for_context()
|
context = handler.prompt_user_for_context()
|
||||||
prompt_bool.assert_not_called()
|
prompt_bool.assert_called_once_with(
|
||||||
|
"use continuum for data versioning?", default=False
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
context, {"db_url": db_url, "wants_continuum": True}
|
context, {"db_url": db_url, "wants_continuum": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# should not prompt if continuum flag already true
|
||||||
|
handler = self.make_handler()
|
||||||
|
with patch("builtins.__import__"): # nb. pretend import is ok
|
||||||
|
with patch.object(handler, "wants_continuum", new=True):
|
||||||
|
with patch.object(handler, "prompt_bool") as prompt_bool:
|
||||||
|
context = handler.prompt_user_for_context()
|
||||||
|
prompt_bool.assert_not_called()
|
||||||
|
self.assertEqual(
|
||||||
|
context, {"db_url": db_url, "wants_continuum": True}
|
||||||
|
)
|
||||||
|
|
||||||
# should not prompt if continuum flag already false
|
# should not prompt if continuum flag already false
|
||||||
handler = self.make_handler()
|
handler = self.make_handler()
|
||||||
with patch.object(handler, "wants_continuum", new=False):
|
with patch("builtins.__import__"): # nb. pretend import is ok
|
||||||
with patch.object(handler, "prompt_bool") as prompt_bool:
|
with patch.object(handler, "wants_continuum", new=False):
|
||||||
context = handler.prompt_user_for_context()
|
with patch.object(handler, "prompt_bool") as prompt_bool:
|
||||||
prompt_bool.assert_not_called()
|
context = handler.prompt_user_for_context()
|
||||||
self.assertEqual(
|
prompt_bool.assert_not_called()
|
||||||
context, {"db_url": db_url, "wants_continuum": False}
|
self.assertEqual(
|
||||||
)
|
context, {"db_url": db_url, "wants_continuum": False}
|
||||||
|
)
|
||||||
|
|
||||||
# should not prompt if continuum pkg missing...
|
# should not prompt if continuum pkg missing...
|
||||||
handler = self.make_handler()
|
handler = self.make_handler()
|
||||||
with patch("builtins.__import__", side_effect=ImportError):
|
with patch("builtins.__import__", side_effect=ImportError): # import fails
|
||||||
with patch.object(handler, "prompt_bool") as prompt_bool:
|
with patch.object(handler, "prompt_bool") as prompt_bool:
|
||||||
context = handler.prompt_user_for_context()
|
context = handler.prompt_user_for_context()
|
||||||
prompt_bool.assert_not_called()
|
prompt_bool.assert_not_called()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue