From 7b7238f156402d9c9ee30899a99f254ba636c63c Mon Sep 17 00:00:00 2001 From: butomo1989 Date: Thu, 6 Apr 2017 16:29:11 +0200 Subject: [PATCH] Run emulator in the beginning --- README.md | 2 +- src/app.py | 9 +++++++-- src/tests/__init__.py | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6bafe10..b8570b4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Quick Start - For different OS, localhost should work. -4. Open ***http://docker-machine-ip-address:6080/vnc.html*** from web browser. +4. Open ***http://docker-machine-ip-address:6080*** from web browser. ![][noVNC] diff --git a/src/app.py b/src/app.py index 07ae6b4..065eddb 100644 --- a/src/app.py +++ b/src/app.py @@ -87,8 +87,7 @@ def prepare_avd(device: str, avd_name: str): # Append command cmd += ' -d {device} -s {skin}'.format(device=device_name_bash, skin=skin_name) logger.info('AVD creation command: {cmd}'.format(cmd=cmd)) - titel = 'AVD creation process' - subprocess.check_call('xterm -T "{titel}" -n "{titel}" -e \"{cmd}\"'.format(titel=titel, cmd=cmd), shell=True) + subprocess.check_call(cmd, shell=True) def appium_run(avd_name: str): @@ -162,9 +161,15 @@ def run(): avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION) logger.info('AVD name: {avd}'.format(avd=avd_name)) + logger.info('Preparing emulator...') prepare_avd(device, avd_name) + logger.info('Run emulator...') + cmd = 'emulator -avd {name}'.format(name=avd_name) + subprocess.Popen(cmd.split()) + appium = str_to_bool(str(os.getenv('APPIUM', True))) if appium: + logger.info('Run appium server...') appium_run(avd_name) if __name__ == '__main__': diff --git a/src/tests/__init__.py b/src/tests/__init__.py index a6e320c..5ec9eee 100644 --- a/src/tests/__init__.py +++ b/src/tests/__init__.py @@ -34,16 +34,20 @@ class TestApp(TestCase): self.assertEqual(app.str_to_bool(True), None) @mock.patch('src.app.prepare_avd') - def test_run_with_appium(self, mocked_avd): + @mock.patch('subprocess.Popen') + def test_run_with_appium(self, mocked_avd, mocked_subprocess): with mock.patch('src.app.appium_run') as mocked_appium: app.run() self.assertTrue(mocked_avd.called) + self.assertTrue(mocked_subprocess.called) self.assertTrue(mocked_appium.called) @mock.patch('src.app.prepare_avd') - def test_run_withhout_appium(self, mocked_avd): + @mock.patch('subprocess.Popen') + def test_run_withhout_appium(self, mocked_avd, mocked_subprocess): with mock.patch('src.app.appium_run') as mocked_appium: os.environ['APPIUM'] = str(False) app.run() self.assertTrue(mocked_avd.called) + self.assertTrue(mocked_subprocess.called) self.assertFalse(mocked_appium.called)