コード例 #1
0
 def test_check_configure_ip_addr_failure(self):
     lst = [Response(""),Response("inet addr:4.0.1.1  Bcast:4.255.255.255  Mask:255.0.0.0")]
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     get_ip_address_type=MagicMock(side_effect="ipv4")
     try:
         configure_ip_address(
                 device=self.mocked_obj,
                 address="4.0.0.1",
                 interface="eth1",
                 mask="255.0.0.0")
     except Exception as err:
         self.assertEqual(
             err.args[0],
             "IPv4/IPv6 address is not configured successfully")
コード例 #2
0
    def test_check_configure_ip_addr_exception(self):
        try:
            configure_ip_address()
        except Exception as err:
            self.assertEqual(
                err.args[0],
                 "device is mandatory argument")

        try:
            configure_ip_address(device=self.mocked_obj)
        except Exception as err:
            self.assertEqual(
                err.args[0],
                 "Interface and IPv4/IPv6 address are mandatory argument")
コード例 #3
0
 def test_check_ipv4_configure_ip_addr_success(self):
     lst = [Response(""),Response("inet addr:4.0.0.1  Bcast:4.255.255.255  Mask:255.0.0.0")]
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     get_ip_address_type=MagicMock(side_effect="ipv4")
     self.assertEqual(
          configure_ip_address(
                 device=self.mocked_obj,
                 address="4.0.0.1",
                 interface="eth1",
                 mask="255.0.0.0"),
                 True)
コード例 #4
0
 def test_check_ipv6_configure_ip_addr_success(self):
     lst = [Response(""),Response("inet6 addr: 2005::1/")]
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     get_ip_address_type=MagicMock(side_effect="ipv6")
     self.assertEqual(
          configure_ip_address(
                 device=self.mocked_obj,
                 address="2005::1",
                 interface="eth1",
                 mask="64"),
                 True)