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
|
||||
if self.wants_continuum is None:
|
||||
try:
|
||||
import wutta_continuum
|
||||
import wutta_continuum # pylint: disable=import-outside-toplevel,unused-import
|
||||
except ImportError:
|
||||
self.wants_continuum = False
|
||||
else:
|
||||
|
|
@ -258,10 +258,7 @@ class InstallHandler(GenericHandler): # pylint: disable=too-many-public-methods
|
|||
"""
|
||||
# get db info/url
|
||||
dbinfo = self.get_dbinfo()
|
||||
if "db_url" in dbinfo:
|
||||
db_url = dbinfo["db_url"]
|
||||
else:
|
||||
db_url = self.make_db_url(dbinfo)
|
||||
db_url = dbinfo.get("db_url", self.make_db_url(dbinfo))
|
||||
|
||||
# test db connection
|
||||
self.rprint("\n\ttesting db connection... ", end="")
|
||||
|
|
|
|||
|
|
@ -86,16 +86,20 @@ class TestInstallHandler(ConfigTestCase):
|
|||
|
||||
# should prompt for continuum by default
|
||||
handler = self.make_handler()
|
||||
with patch("builtins.__import__"): # nb. pretend import is ok
|
||||
with patch.object(handler, "prompt_bool") as prompt_bool:
|
||||
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})
|
||||
self.assertEqual(
|
||||
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()
|
||||
|
|
@ -106,6 +110,7 @@ class TestInstallHandler(ConfigTestCase):
|
|||
|
||||
# should not prompt if continuum flag already false
|
||||
handler = self.make_handler()
|
||||
with patch("builtins.__import__"): # nb. pretend import is ok
|
||||
with patch.object(handler, "wants_continuum", new=False):
|
||||
with patch.object(handler, "prompt_bool") as prompt_bool:
|
||||
context = handler.prompt_user_for_context()
|
||||
|
|
@ -116,7 +121,7 @@ class TestInstallHandler(ConfigTestCase):
|
|||
|
||||
# should not prompt if continuum pkg missing...
|
||||
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:
|
||||
context = handler.prompt_user_for_context()
|
||||
prompt_bool.assert_not_called()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue