def testScenarioFromSrpy(self): # test that compilation and resurrection give the same scenario self.scenario = get_test_scenario_from_file('stest.py') compile_scenario('stest.py') self.assertTrue(os.stat('stest.srpy') != None) self.scenario_compiled = get_test_scenario_from_file('stest.srpy') self.assertIsInstance(self.scenario_compiled, Scenario) self.assertEqual(self.scenario, self.scenario_compiled)
def testScenarioFromSrpy(self): # test that compilation and resurrection give the same scenario self.scenario = get_test_scenario_from_file('stest.py') compile_scenario('stest.py') self.assertTrue(os.stat('stest.srpy') != None) self.scenario_compiled = get_test_scenario_from_file('stest.srpy') self.assertIsInstance(self.scenario_compiled, TestScenario) self.assertEqual(self.scenario, self.scenario_compiled)
def testInterfaces(self): self.scenario = get_test_scenario_from_file('stest.py') p = self.scenario.ports() self.assertIn('router-eth0', p) self.assertIn('router-eth1', p) self.assertIn('router-eth2', p) self.assertIn('router-eth3', p)
def testNoMorePending(self): self.scenario = get_test_scenario_from_file('stest.py') s = copy.deepcopy(self.scenario) s.pending_events.pop() s.next() s.testpass() self.assertRaises(ScenarioFailure, s.next)
def testNoMorePending(self): self.scenario = get_test_scenario_from_file('stest.py') s = copy.deepcopy(self.scenario) s._pending_events.pop() s.next() s.testpass() self.assertRaises(TestScenarioFailure, s.next)
def testScenarioFromPy(self): self.scenario = get_test_scenario_from_file('stest.py') self.assertIsInstance(self.scenario, Scenario) self.assertIsInstance(self.scenario.next(), PacketInputEvent) self.scenario.testpass() self.assertIsInstance(self.scenario.next(), PacketOutputEvent) self.scenario.testpass() self.assertRaises(ScenarioFailure, self.scenario.next)
def testScenarioFromPy(self): self.scenario = get_test_scenario_from_file('stest.py') self.assertIsInstance(self.scenario, TestScenario) self.assertIsInstance(self.scenario.next(), PacketInputEvent) self.scenario.testpass() self.assertIsInstance(self.scenario.next(), PacketOutputEvent) self.scenario.testpass() self.assertRaises(TestScenarioFailure, self.scenario.next)
def testScenarioSanity(self): self.scenario = get_test_scenario_from_file('stest.py') self.scenario.scenario_sanity_check()
def testSlowOutput(self): self.scenario = get_test_scenario_from_file('stest.py') self.scenario.next() self.scenario.testpass() self.scenario.next() self.assertRaises(ScenarioFailure, time.sleep, 61)
def testSlowOutput(self): self.scenario = get_test_scenario_from_file('stest.py') self.scenario.next() self.scenario.testpass() self.scenario.next() self.assertRaises(TestScenarioFailure, time.sleep, 61)
def testCleanScenario(self): scen = get_test_scenario_from_file('stest') self.assertFalse(scen.done()) self.assertEqual(len(scen.pending_events), 4) self.assertListEqual(scen.completed_events, [])