How to use label_remove_hosts method in autotest

Best Python code snippet using autotest_python

label_unittest.py

Source:label_unittest.py Github

copy

Full Screen

1#!/usr/bin/python2#3# Copyright 2008 Google Inc. All Rights Reserved.4"""Tests for label."""5import unittest6import sys7import os8try:9 import autotest.common as common10except ImportError:11 import common12from autotest.cli import cli_mock, topic_common13class label_list_unittest(cli_mock.cli_unittest):14 values = [{u'id': 180, # Valid label15 u'platform': False,16 u'name': u'label0',17 u'invalid': False,18 u'kernel_config': u'',19 u'only_if_needed': False},20 {u'id': 338, # Valid label21 u'platform': False,22 u'name': u'label1',23 u'invalid': False,24 u'kernel_config': u'',25 u'only_if_needed': False},26 {u'id': 340, # Invalid label27 u'platform': False,28 u'name': u'label2',29 u'invalid': True,30 u'kernel_config': u'',31 u'only_if_needed': False},32 {u'id': 350, # Valid platform33 u'platform': True,34 u'name': u'plat0',35 u'invalid': False,36 u'kernel_config': u'',37 u'only_if_needed': False},38 {u'id': 420, # Invalid platform39 u'platform': True,40 u'name': u'plat1',41 u'invalid': True,42 u'kernel_config': u'',43 u'only_if_needed': False}]44 def test_label_list_labels_only(self):45 self.run_cmd(argv=['atest', 'label', 'list', '--ignore_site_file'],46 rpcs=[('get_labels', {}, True, self.values)],47 out_words_ok=['label0', 'label1', 'label2'],48 out_words_no=['plat0', 'plat1'])49 def test_label_list_labels_only_valid(self):50 self.run_cmd(argv=['atest', 'label', 'list', '-d',51 '--ignore_site_file'],52 rpcs=[('get_labels', {}, True, self.values)],53 out_words_ok=['label0', 'label1'],54 out_words_no=['label2', 'plat0', 'plat1'])55 def test_label_list_labels_and_platforms(self):56 self.run_cmd(argv=['atest', 'label', 'list', '--all',57 '--ignore_site_file'],58 rpcs=[('get_labels', {}, True, self.values)],59 out_words_ok=['label0', 'label1', 'label2',60 'plat0', 'plat1'])61 def test_label_list_platforms_only(self):62 self.run_cmd(argv=['atest', 'label', 'list', '-t',63 '--ignore_site_file'],64 rpcs=[('get_labels', {}, True, self.values)],65 out_words_ok=['plat0', 'plat1'],66 out_words_no=['label0', 'label1', 'label2'])67 def test_label_list_platforms_only_valid(self):68 self.run_cmd(argv=['atest', 'label', 'list',69 '-t', '--valid-only', '--ignore_site_file'],70 rpcs=[('get_labels', {}, True, self.values)],71 out_words_ok=['plat0'],72 out_words_no=['label0', 'label1', 'label2',73 'plat1'])74class label_create_unittest(cli_mock.cli_unittest):75 def test_execute_create_two_labels(self):76 self.run_cmd(argv=['atest', 'label', 'create', 'label0', 'label1',77 '--ignore_site_file'],78 rpcs=[('add_label',79 {'name': 'label0', 'platform': False,80 'only_if_needed': False},81 True, 42),82 ('add_label',83 {'name': 'label1', 'platform': False,84 'only_if_needed': False},85 True, 43)],86 out_words_ok=['Created', 'label0', 'label1'])87 def test_execute_create_two_labels_bad(self):88 self.run_cmd(argv=['atest', 'label', 'create', 'label0', 'label1',89 '--ignore_site_file'],90 rpcs=[('add_label',91 {'name': 'label0', 'platform': False,92 'only_if_needed': False},93 True, 3),94 ('add_label',95 {'name': 'label1', 'platform': False,96 'only_if_needed': False},97 False,98 '''ValidationError: {'name':99 'This value must be unique (label0)'}''')],100 out_words_ok=['Created', 'label0'],101 out_words_no=['label1'],102 err_words_ok=['label1', 'ValidationError'])103class label_delete_unittest(cli_mock.cli_unittest):104 def test_execute_delete_labels(self):105 self.run_cmd(argv=['atest', 'label', 'delete', 'label0', 'label1',106 '--ignore_site_file'],107 rpcs=[('delete_label', {'id': 'label0'}, True, None),108 ('delete_label', {'id': 'label1'}, True, None)],109 out_words_ok=['Deleted', 'label0', 'label1'])110class label_add_unittest(cli_mock.cli_unittest):111 def test_execute_add_labels_to_hosts(self):112 self.run_cmd(argv=['atest', 'label', 'add', 'label0',113 '--machine', 'host0,host1', '--ignore_site_file'],114 rpcs=[('label_add_hosts', {'id': 'label0',115 'hosts': ['host1', 'host0']},116 True, None)],117 out_words_ok=['Added', 'label0', 'host0', 'host1'])118class label_remove_unittest(cli_mock.cli_unittest):119 def test_execute_remove_labels_from_hosts(self):120 self.run_cmd(argv=['atest', 'label', 'remove', 'label0',121 '--machine', 'host0,host1', '--ignore_site_file'],122 rpcs=[('label_remove_hosts', {'id': 'label0',123 'hosts': ['host1', 'host0']},124 True, None)],125 out_words_ok=['Removed', 'label0', 'host0', 'host1'])126if __name__ == '__main__':...

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