def verify_prerequisite(self, uut): ''' ''' # Perform init steps here # Call our parser parser = ShowIpArp(device=uut) output = parser.parse() self.initial_output = {} for addr, value in output.items(): if 'age' in value: self.initial_output[addr] = {} self.initial_output[addr]['age'] = value['age']
def verify_clear(self, uut, sleep): time.sleep(sleep) # Call our parser parser = ShowIpArp(device=uut) try: after_output = parser.parse() except SchemaEmptyParserError: # If only 1 arp, then it will return empty, which is perfectly fine pass for addr, value in self.initial_output.items(): if addr not in after_output: # Lost an arp! self.failed('Lost {addr}'.format(addr=addr)) # Make sure uptime is less than 30 sec if not after_output[addr]['Age'] == '-' and\ after_output[addr]['Age'] > 30 or\ after_output[addr]['Age'] > self.initial_output[addr]['Age']: self.failed('{addr} was not reseted'.format(addr=addr))
def test_golden_all(self): self.device = Mock(**self.golden_output_3) obj = ShowIpArp(device=self.device) parsed_output = obj.parse(vrf='all') self.assertEqual(parsed_output, self.golden_parsed_output_3)
def test_golden_vrf(self): self.device = Mock(**self.golden_output_2) obj = ShowIpArp(device=self.device) parsed_output = obj.parse(vrf='vni_10100') self.assertEqual(parsed_output, self.golden_parsed_output_2)
def test_golden(self): self.device = Mock(**self.golden_output) obj = ShowIpArp(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output)
def test_empty(self): self.device = Mock(**self.empty_output) obj = ShowIpArp(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse()