コード例 #1
0
 def test_check_check_ping_connection_unsuccess_6(self):
     lst = [Response("No route to host")]
     _get_ip_address_type = MagicMock(side_effect="ipv4")
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     try:
         check_ping_connection(device=self.mocked_obj,
                               destination="4.0.0.1",
                               source="4.0.0.2",
                               count="5",
                               packetsize="64",
                               ttl="10")
     except Exception as err:
         self.assertEqual(err.args[0], "No route to host")
コード例 #2
0
 def test_check_check_ping_connection_unsuccess_2(self):
     lst = [Response("bind Cannot assign requested address")]
     _get_ip_address_type = MagicMock(side_effect="ipv4")
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     try:
         check_ping_connection(device=self.mocked_obj,
                               destination="4.0.0.1",
                               source="4.0.0.2",
                               count="5")
     except Exception as err:
         self.assertEqual(
             err.args[0],
             "Ping failed with error Cannot assign requested address")
コード例 #3
0
 def test_check_check_ping_connection_negative_unsuccess_1(self):
     lst = [
         Response(
             "4 packets transmitted, 4 received, 0% packet loss, time 3806ms"
         )
     ]
     _get_ip_address_type = MagicMock(side_effect="ipv4")
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     try:
         check_ping_connection(device=self.mocked_obj,
                               destination="4.0.0.1",
                               source="4.0.0.2",
                               negative=True,
                               count="5")
     except Exception as err:
         self.assertEqual(err.args[0], "no packet loss, Ping successful")
コード例 #4
0
 def test_check_check_ping_connection_unsuccess_3(self):
     lst = [
         Response(
             "4 packets transmitted, 2 received, 50% packet loss, time 3806ms"
         )
     ]
     _get_ip_address_type = MagicMock(side_effect="ipv4")
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     try:
         check_ping_connection(device=self.mocked_obj,
                               destination="4.0.0.1",
                               source="4.0.0.2",
                               count="5",
                               packetsize="64",
                               ttl="10")
     except Exception as err:
         self.assertEqual(err.args[0],
                          "All packets not received, Ping unsuccessful")
コード例 #5
0
 def test_check_check_ping_connection_ipv6_success(self):
     lst = [
         Response(
             "4 packets transmitted, 4 received, 0% packet loss, time 3806ms"
         )
     ]
     _get_ip_address_type = MagicMock(side_effect="ipv6")
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     self.assertEqual(
         check_ping_connection(device=self.mocked_obj,
                               destination="2005::1",
                               source="2004::1"),
         "4 packets transmitted, 4 received, 0% packet loss, time 3806ms")
コード例 #6
0
    def test_check_check_ping_connection_exception(self):
        try:
            check_ping_connection()
        except Exception as err:
            self.assertEqual(err.args[0], "device is mandatory argument")

        try:
            check_ping_connection(device=self.mocked_obj)
        except Exception as err:
            self.assertEqual(err.args[0], "destination is mandatory argument")
        lst = [
            Response(
                "4 packets transmitted, 4 received, 0% packet loss, time 3806ms"
            )
        ]
        _get_ip_address_type = MagicMock(side_effect="ipv4")
        self.mocked_obj.shell = MagicMock(side_effect=lst)
        self.assertEqual(
            check_ping_connection(device=self.mocked_obj,
                                  destination="4.0.0.1",
                                  source=None,
                                  count="5",
                                  strict_check=False),
            "4 packets transmitted, 4 received, 0% packet loss, time 3806ms")
コード例 #7
0
 def test_check_check_ping_connection_ipv4_success(self):
     lst = [
         Response(
             "4 packets transmitted, 4 received, 0% packet loss, time 3806ms"
         )
     ]
     _get_ip_address_type = MagicMock(side_effect="ipv4")
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     self.assertEqual(
         check_ping_connection(device=self.mocked_obj,
                               destination="4.0.0.1",
                               source="4.0.0.2",
                               rapid_ping=True,
                               interval="5",
                               count="5"),
         "4 packets transmitted, 4 received, 0% packet loss, time 3806ms")