Ejemplo n.º 1
0
 def DONTtest_generate_one(self):
     log = self.__scenario.generate_one()
     regexp = r'date="(?P<date>.*)" src="(?P<src>.*)" dst="(?P<dst>.*)" recv="(?P<recv>.*)" sent="(?P<sent>.*)" user_agent="(?P<user_agent>.*)" respond_code="(?P<respond_code>.*)"'
     m = re.match(regexp,log)
     self.assertTrue(m)
     date = m.group('date')
     self.assertEqual(datetime.strptime(date, "%Y/%m/%d %H:%S:%M").strftime("%Y/%m/%d %H:%S:%M"), date)
     src = m.group('src')
     self.assertTrue(is_valid_ipv4(src))
     dst = m.group('dst')
     self.assertTrue(is_valid_ipv4(dst))
     recv = int(m.group('recv'))
     self.assertLessEqual(recv, 1000000)
     sent = int(m.group('sent'))
     self.assertLessEqual(sent, 1000000)
Ejemplo n.º 2
0
 def test_generate(self):
     s = Ipv4Generator({})
     self.assertTrue(is_valid_ipv4(s.generate()))