def setUp(self): engine = EngineEmul() engine.config.merge({'services': {'appium-loader': {}}}) self.check_if_appium_started = AppiumLoader.tool_is_started AppiumLoader.tool_is_started = lambda slf: True self.appium = AppiumLoader() self.appium.engine = engine self.appium.settings = engine.config['services']['appium-loader'] self.check_if_node_installed = Node.check_if_installed self.check_if_java_installed = JavaVM.check_if_installed Node.check_if_installed = lambda slf: True JavaVM.check_if_installed = lambda slf: True
class TestAppiumLoader(BZTestCase): def setUp(self): engine = EngineEmul() engine.config.merge({'services': {'appium-loader': {}}}) self.check_if_appium_started = AppiumLoader.tool_is_started AppiumLoader.tool_is_started = lambda slf: True self.appium = AppiumLoader() self.appium.engine = engine self.appium.settings = engine.config['services']['appium-loader'] self.check_if_node_installed = Node.check_if_installed self.check_if_java_installed = JavaVM.check_if_installed Node.check_if_installed = lambda slf: True JavaVM.check_if_installed = lambda slf: True def tearDown(self): AppiumLoader.tool_is_started = self.check_if_appium_started Node.check_if_installed = self.check_if_node_installed JavaVM.check_if_installed = self.check_if_java_installed def test_appium_not_installed(self): self.appium.settings['path'] = 'wrong_path' self.assertRaises(ToolError, self.appium.prepare) def test_appium_full_cycle(self): self.create_fake_appium() self.appium.prepare() self.appium.startup() self.appium.shutdown() self.appium.post_process() def create_fake_appium(self): src_dir = RESOURCES_DIR + 'appium' dest_dir = self.appium.engine.artifacts_dir shutil.copy2(join(src_dir, 'appium' + EXE_SUFFIX), dest_dir) os.chmod(join(dest_dir, 'appium' + EXE_SUFFIX), 0o755) shutil.copy2(join(src_dir, 'appium.py'), dest_dir) self.appium.settings['path'] = join(dest_dir, 'appium' + EXE_SUFFIX)