How to use get_server_dir method in autotest

Best Python code snippet using autotest_python

base_classes_unittest.py

Source:base_classes_unittest.py Github

copy

Full Screen

1#!/usr/bin/python2# pylint: disable=missing-docstring3import unittest4import common5from autotest_lib.client.common_lib import global_config6from autotest_lib.client.common_lib.test_utils import mock7from autotest_lib.server import utils8from autotest_lib.server.hosts import base_classes9class test_host_class(unittest.TestCase):10 def setUp(self):11 self.god = mock.mock_god()12 # stub out get_server_dir, global_config.get_config_value13 self.god.stub_with(utils, "get_server_dir",14 lambda: "/unittest/server")15 self.god.stub_function(global_config.global_config,16 "get_config_value")17 def tearDown(self):18 self.god.unstub_all()19 def test_init(self):20 self.god.stub_function(utils, "get_server_dir")21 host = base_classes.Host.__new__(base_classes.Host)22 # set up the recording23 utils.get_server_dir.expect_call().and_return("/unittest/server")24 # run the actual test25 host.__init__()26 self.god.check_playback()27 def test_install(self):28 host = base_classes.Host()29 # create a dummy installable class30 class installable(object):31 def install(self, host):32 pass33 installableObj = self.god.create_mock_class(installable,34 "installableObj")35 installableObj.install.expect_call(host)36 # run the actual test37 host.install(installableObj)38 self.god.check_playback()39 def test_get_wait_up_empty(self):40 global_config.global_config.get_config_value.expect_call(41 "HOSTS", "wait_up_processes", default="").and_return("")42 host = base_classes.Host()43 self.assertEquals(host.get_wait_up_processes(), set())44 self.god.check_playback()45 def test_get_wait_up_ignores_whitespace(self):46 global_config.global_config.get_config_value.expect_call(47 "HOSTS", "wait_up_processes", default="").and_return(" ")48 host = base_classes.Host()49 self.assertEquals(host.get_wait_up_processes(), set())50 self.god.check_playback()51 def test_get_wait_up_single_process(self):52 global_config.global_config.get_config_value.expect_call(53 "HOSTS", "wait_up_processes", default="").and_return("proc1")54 host = base_classes.Host()55 self.assertEquals(host.get_wait_up_processes(),56 set(["proc1"]))57 self.god.check_playback()58 def test_get_wait_up_multiple_process(self):59 global_config.global_config.get_config_value.expect_call(60 "HOSTS", "wait_up_processes", default="").and_return(61 "proc1,proc2,proc3")62 host = base_classes.Host()63 self.assertEquals(host.get_wait_up_processes(),64 set(["proc1", "proc2", "proc3"]))65 self.god.check_playback()66 def test_get_wait_up_drops_duplicates(self):67 global_config.global_config.get_config_value.expect_call(68 "HOSTS", "wait_up_processes", default="").and_return(69 "proc1,proc2,proc1")70 host = base_classes.Host()71 self.assertEquals(host.get_wait_up_processes(),72 set(["proc1", "proc2"]))73 self.god.check_playback()74if __name__ == "__main__":...

Full Screen

Full Screen

server_zip_resource.py

Source:server_zip_resource.py Github

copy

Full Screen

...24 self._version = asset_version25 self._status = ServerStatus.UNINITIALIZED26 self._hash = asset_hash27 self._executables = executables28 def get_server_dir(self) -> str:29 return os.path.join(self._storage_path, self._package_name, "server", self._version)30 def get_server_exec(self) -> str:31 return os.path.join(self.get_server_dir(), self._binary_path)32 def is_server_downloaded(self):33 return os.path.exists(self.get_server_exec())34 def is_valid_hash(self, path, expected) -> bool:35 if not self._hash:36 return True37 with open(path, "rb") as f:38 calculated = hashlib.sha256(f.read()).hexdigest()39 return calculated == expected40 def unpack_server(self, zip_file) -> None:41 if not self.is_valid_hash(zip_file, self._hash):42 return43 target_dir = self.get_server_dir()44 os.makedirs(target_dir, exist_ok=True)45 with ZipFile(zip_file, "r") as f:46 f.extractall(target_dir)47 # ZipFile removes permissions, make server executable48 if self._executables and not sublime.platform() == 'windows':49 for executable in self._executables:50 os.chmod(os.path.join(target_dir, executable), 0o755)51 def download_server(self) -> None:52 target = sublime.active_window()53 label = "Downloading zip file..."54 with ActivityIndicator(target, label):55 tmp_file, _ = urlretrieve(self._url)56 self.unpack_server(tmp_file)57 os.unlink(tmp_file)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful