示例#1
0
 def test__creates_omshell_with_correct_arguments(self):
     omshell = self.patch(dhcp, "Omshell")
     server = Mock()
     server.ipv6 = factory.pick_bool()
     dhcp._update_hosts(server, [], [], [])
     self.assertThat(omshell, MockCallsMatch(
         call(
             ipv6=server.ipv6, server_address="127.0.0.1",
             shared_key=server.omapi_key),
     ))
示例#2
0
 def test_performs_operations(self):
     remove_host = make_host()
     add_host = make_host()
     modify_host = make_host()
     omapi_cli = Mock()
     self.patch(dhcp, "OmapiClient").return_value = omapi_cli
     dhcp._update_hosts(Mock(), [remove_host], [add_host], [modify_host])
     self.assertEqual(
         omapi_cli.mock_calls,
         [
             call.del_host(remove_host["mac"]),
             call.add_host(add_host["mac"], add_host["ip"]),
             call.update_host(modify_host["mac"], modify_host["ip"]),
         ],
     )
示例#3
0
文件: test_dhcp.py 项目: zhangrb/maas
 def test__performs_operations(self):
     omshell = Mock()
     self.patch(dhcp, "Omshell").return_value = omshell
     remove_host = make_host()
     add_host = make_host()
     modify_host = make_host()
     server = Mock()
     server.ipv6 = factory.pick_bool()
     dhcp._update_hosts(server, [remove_host], [add_host], [modify_host])
     self.assertThat(omshell.remove,
                     MockCallsMatch(call(remove_host["mac"]), ))
     self.assertThat(
         omshell.create,
         MockCallsMatch(call(add_host["ip"], add_host["mac"]), ))
     self.assertThat(
         omshell.modify,
         MockCallsMatch(call(modify_host["ip"], modify_host["mac"]), ))
示例#4
0
 def test_creates_client_with_correct_arguments(self):
     omapi_cli = self.patch(dhcp, "OmapiClient")
     server = Mock()
     server.ipv6 = factory.pick_bool()
     dhcp._update_hosts(server, [], [], [])
     omapi_cli.assert_called_once_with(server.omapi_key, server.ipv6)