def test_main(self):
        print("This is runTest of Test1")

        # working with TestStep variant
        with TS(self, "execute step 1") as ts:
            ts.call(self.set_action_1)
            ts.verify(ts.result[-1].output() == 100, "step 1 verification")
        with TS(self, "execute step 2") as ts:
            ts.call(self.set_action_2)
            ts.verify(ts.result[-1].output() == 200, "step 2 verification")
def test_negative_scenario3(obj):
    # this scenario will throw an exception Code Error as no exception got raised
    with pytest.raises(AssertionError) as exc:
        with TS(obj, "Negative Test Scenario 7", type(obj).__name__) as ts:
            with ts.assertRaises(KeyError):
                ts.call(print, "I won't throw an exception")
    assert "No exception caught" in str(exc.value)
def test_negative_scenario1(obj):
    # this scenario will throw an exception Code Error
    with pytest.raises(AssertionError) as exc:
        with TS(obj, "Negative Test Scenario 5", type(obj).__name__) as ts:
            with ts.assertRaises(KeyError):
                ts.call(obj.action)
    assert exc.type is AssertionError
 def test_negative_scenario2(self):
     # this scenario will throw an exception Code Error
     with pytest.raises(AssertionError) as exc:
         with TS(self, "Negative Test Scenario 6",
                 type(self).__name__) as ts:
             ts.assertRaises(KeyError, self.action, code=100)
     assert exc.type is AssertionError
def test_positive_scenario3(obj):
    # should be able to continue remaining execution after with, if any.
    with TS(obj, "Negative Test Scenario 3", type(obj).__name__) as ts:
        with ts.assertRaises(ValueError) as e:
            ts.call(obj.action)
        ts.call(print, "Yes I work")
        exc = e.exception
        assert exc.code == 200
Beispiel #6
0
 def test_main(self):
     param_list = [
         "Device.WiFi.Radio.2.Channel",
         "Device.WiFi.Radio.2.OperatingChannelBandwidth",
         "Device.DeviceInfo.FirstUseDate",
         "Device.ManagementServer.PeriodicInformEnable",
         "Device.DeviceInfo.SoftwareVersion",
         "Device.DeviceInfo.Description",
         "Device.Ethernet.Interface.1.Alias",
     ]
     try:
         capture_file = "acs_pktc.pcap"
         with TS(self, "To induce Dos attack", prefix="Test") as ts:
             count = 0
             ts.call(
                 tcpdump_capture,
                 self.dev.acs_server,
                 "any",
                 capture_file=capture_file,
             )
             for param in param_list:
                 count += 1
                 ts.call(self.dev.acs_server.GPV, param)
     except HTTPError as e:
         if "507" in str(e):
             with TS(self, "To verify packet capture", prefix="Test") as ts:
                 ts.call(kill_process,
                         self.dev.acs_server,
                         process="tcpdump")
                 ts.call(
                     tshark_read,
                     self.dev.acs_server,
                     capture_file,
                     filter_str=
                     '-T fields -e http.response.code | grep "503"',
                 )
                 ts.verify(
                     "503" in ts.result[-1].output(),
                     "Dos attack happened at " + str(count) + "th GPV",
                 )
         else:
             print("No Dos attack")
     finally:
         with TS(self, "Kill tcpdump", prefix="Test") as ts:
             ts.call(kill_process, self.dev.acs_server, process="tcpdump")
def test_positive_scenario4(obj):
    # should be able to continue remaining execution after with, if any.
    with TS(obj, "Negative Test Scenario 4", type(obj).__name__) as ts:
        exc = ts.assertRaises(ValueError, obj.action, code=300).exception
        ts.call(print, "Yes I work")
        assert exc.code == 300
def test_positive_scenario2(obj):
    with TS(obj, "Negative Test Scenario 2", type(obj).__name__) as ts:
        exc = ts.assertRaises(ValueError, obj.action, code=300).exception
        assert exc.code == 300
def test_positive_scenario1(obj):
    with TS(obj, "Negative Test Scenario 1", type(obj).__name__) as ts:
        with ts.assertRaises(ValueError) as e:
            ts.call(obj.action)
        exc = e.exception
        assert exc.code == 200
Beispiel #10
0
 def runTest(self):
     with TS(self, "TD selftest. Print action1 output") as ts:
         ts.call(self.action_1, "Executed Action 1")
Beispiel #11
0
 def test_main(self):
     """A sample test class to validate teardown feature."""
     with TS(self, "TD selftest. Print action1 output") as ts:
         ts.call(self.action_1, "Executed Action 1")