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), ))
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"]), ], )
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"]), ))
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)