Best Python code snippet using tempest_python
test_workspace.py
Source:test_workspace.py
...30 self.workspace_manager = workspace.WorkspaceManager(31 path=self.store_file)32 self.workspace_manager.register_new_workspace(self.name, self.path)33class TestTempestWorkspace(TestTempestWorkspaceBase):34 def _run_cmd_gets_return_code(self, cmd, expected):35 process = subprocess.Popen(cmd, stdout=subprocess.PIPE,36 stderr=subprocess.PIPE)37 stdout, stderr = process.communicate()38 return_code = process.returncode39 msg = ("%s failed with:\nstdout: %s\nstderr: %s" % (' '.join(cmd),40 stdout, stderr))41 self.assertEqual(return_code, expected, msg)42 def test_run_workspace_list(self):43 cmd = ['tempest', 'workspace', 'list',44 '--workspace-path', self.store_file]45 self._run_cmd_gets_return_code(cmd, 0)46 def test_run_workspace_register(self):47 name = data_utils.rand_uuid()48 path = tempfile.mkdtemp()49 self.addCleanup(shutil.rmtree, path, ignore_errors=True)50 cmd = ['tempest', 'workspace', 'register',51 '--workspace-path', self.store_file,52 '--name', name, '--path', path]53 self._run_cmd_gets_return_code(cmd, 0)54 self.assertIsNotNone(self.workspace_manager.get_workspace(name))55 def test_run_workspace_rename(self):56 new_name = data_utils.rand_uuid()57 cmd = ['tempest', 'workspace', 'rename',58 '--workspace-path', self.store_file,59 '--old-name', self.name, '--new-name', new_name]60 self._run_cmd_gets_return_code(cmd, 0)61 self.assertIsNone(self.workspace_manager.get_workspace(self.name))62 self.assertIsNotNone(self.workspace_manager.get_workspace(new_name))63 def test_run_workspace_move(self):64 new_path = tempfile.mkdtemp()65 self.addCleanup(shutil.rmtree, new_path, ignore_errors=True)66 cmd = ['tempest', 'workspace', 'move',67 '--workspace-path', self.store_file,68 '--name', self.name, '--path', new_path]69 self._run_cmd_gets_return_code(cmd, 0)70 self.assertEqual(71 self.workspace_manager.get_workspace(self.name), new_path)72 def test_run_workspace_remove_entry(self):73 cmd = ['tempest', 'workspace', 'remove',74 '--workspace-path', self.store_file,75 '--name', self.name]76 self._run_cmd_gets_return_code(cmd, 0)77 self.assertIsNone(self.workspace_manager.get_workspace(self.name))78 def test_run_workspace_remove_directory(self):79 cmd = ['tempest', 'workspace', 'remove',80 '--workspace-path', self.store_file,81 '--name', self.name, '--rmdir']82 self._run_cmd_gets_return_code(cmd, 0)83 self.assertIsNone(self.workspace_manager.get_workspace(self.name))84class TestTempestWorkspaceManager(TestTempestWorkspaceBase):85 def setUp(self):86 super(TestTempestWorkspaceManager, self).setUp()87 self.name = data_utils.rand_uuid()88 self.path = tempfile.mkdtemp()89 self.addCleanup(shutil.rmtree, self.path, ignore_errors=True)90 store_dir = tempfile.mkdtemp()91 self.addCleanup(shutil.rmtree, store_dir, ignore_errors=True)92 self.store_file = os.path.join(store_dir, 'workspace.yaml')93 self.workspace_manager = workspace.WorkspaceManager(94 path=self.store_file)95 self.workspace_manager.register_new_workspace(self.name, self.path)96 def test_workspace_manager_get(self):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!