def test_true_false() -> None: """Test TGN true and false values.""" for false_stc in ("False", "false", "0", "null", "NONE", "none", "::ixnet::obj-null"): assert is_false(false_stc) assert not is_true(false_stc) for true_str in ("True", "TRUE", "1"): assert is_true(true_str) assert not is_false(true_str)
def test_true_false(self): """ Test TGN true and false values. """ for false_stc in ('False', 'false', '0', 'null', 'NONE', 'none', '::ixnet::obj-null'): assert (is_false(false_stc)) assert (not is_true(false_stc)) for true_str in ('True', 'TRUE', '1'): assert (is_true(true_str)) assert (not is_false(true_str))
def test_get_set_attribute(self): self.test_load_config() device = self.stc.project.get_ports()['Port 1'].get_devices( )['Device 1'] # Get all attributes print(device.get_attributes()) # Get group of attributes print(device.get_attributes('RouterId', 'RouterIdStep')) # Get specific attribute print('RouterId: ' + device.get_attribute('RouterId')) # Special cases - name and active print('name: ' + device.get_name()) print('enabled: ' + str(device.get_active())) # Set attribute device.set_attributes(RouterId='1.2.3.4') assert (device.get_attribute('RouterId') == '1.2.3.4') # And again, special case for active device.set_active(False) assert (is_false(device.get_active()))
def get_set_attribute() -> None: """Demonstrates how to set attributes.""" device = stc.project.ports["Port 1"].devices["Device 1"] # Get all attributes print(device.get_attributes()) # Get group of attributes print(device.get_attributes("RouterId", "RouterIdStep")) # Get specific attribute print("RouterId: " + device.get_attribute("RouterId")) # Special cases - name and active print("name: " + device.get_name()) print("enabled: " + str(device.get_active())) # Set attribute device.set_attributes(RouterId="1.2.3.4") assert device.get_attribute("RouterId") == "1.2.3.4" # And again, special case for active device.set_active(False) assert is_false(device.get_active())
def _get_result_data(self, rvd, num_columns): self.project.command('ExpandResultViewDataCommand', ResultViewData=rvd.ref) for child_rvd in rvd.get_children('ResultViewData'): if is_false(child_rvd.get_attribute('IsDummy')): self.objs_stats.append( child_rvd.get_list_attribute('ResultData')[:num_columns]) self._get_result_data(child_rvd, num_columns)
def _get_result_data(self, rvd, num_columns): StcObject.project.command("ExpandResultViewDataCommand", ResultViewData=rvd.ref) for child_rvd in rvd.get_children("ResultViewData"): if is_false(child_rvd.get_attribute("IsDummy")): self.objs_stats.append( child_rvd.get_list_attribute("ResultData")[:num_columns]) self._get_result_data(child_rvd, num_columns)
def _get_pages(self): page = self.ixn_view.get_child_static('page') if is_false(page.get_attribute('isReady')): raise TgnError('"{}" not ready'.format(self.obj_type())) caption = page.get_list_attribute('columnCaptions') rows = [] page.set_attributes(pageSize=50) for page_num in range(1, int(page.get_attribute('totalPages')) + 1): page.set_attributes(commit=True, currentPage=page_num) rows += page.get_list_attribute('pageValues') return caption, rows