Renamed method to fix codacy violation

This commit is contained in:
butomo1989 2017-05-24 11:52:48 +02:00
parent e9ed10d08c
commit d379133801
2 changed files with 10 additions and 10 deletions

View file

@ -26,7 +26,7 @@ def get_or_raise(env: str) -> str:
return env_value
def str_to_bool(str: str) -> bool:
def convert_str_to_bool(str: str) -> bool:
"""
Convert string to boolean.
@ -101,7 +101,7 @@ def appium_run(avd_name: str):
"""
cmd = 'appium'
grid_connect = str_to_bool(str(os.getenv('CONNECT_TO_GRID', False)))
grid_connect = convert_str_to_bool(str(os.getenv('CONNECT_TO_GRID', False)))
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
if grid_connect:
try:
@ -170,7 +170,7 @@ def run():
cmd = 'emulator -avd {name}'.format(name=avd_name)
subprocess.Popen(cmd.split())
appium = str_to_bool(str(os.getenv('APPIUM', False)))
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
if appium:
logger.info('Run appium server...')
appium_run(avd_name)

View file

@ -21,17 +21,17 @@ class TestApp(TestCase):
app.get_or_raise('ENV_2')
def test_valid_bool(self):
self.assertEqual(app.str_to_bool('True'), True)
self.assertEqual(app.str_to_bool('t'), True)
self.assertEqual(app.str_to_bool('1'), True)
self.assertEqual(app.str_to_bool('YES'), True)
self.assertEqual(app.convert_str_to_bool('True'), True)
self.assertEqual(app.convert_str_to_bool('t'), True)
self.assertEqual(app.convert_str_to_bool('1'), True)
self.assertEqual(app.convert_str_to_bool('YES'), True)
def test_invalid_bool(self):
self.assertEqual(app.str_to_bool(''), False)
self.assertEqual(app.str_to_bool('test'), False)
self.assertEqual(app.convert_str_to_bool(''), False)
self.assertEqual(app.convert_str_to_bool('test'), False)
def test_invalid_format(self):
self.assertEqual(app.str_to_bool(True), None)
self.assertEqual(app.convert_str_to_bool(True), None)
@mock.patch('src.app.prepare_avd')
@mock.patch('subprocess.Popen')