def test_save(self, mock_communicator, mock_client, test_input, expected): mock_communicator.send_message = MagicMock() module = IqModule(mock_communicator) client_entry_name = test_input module.save(self._CLIENT_NAME, client_entry_name) assert mock_communicator.send_message.call_args == call( bytearray(expected))
def test_save_all(self, mock_communicator, mock_client): module = IqModule(mock_communicator) module.save = MagicMock() module.save.return_value = "test" num_client_entries = len(mock_client.client_entries) module.save_all(self._CLIENT_NAME) assert module.save.call_count == num_client_entries
def test_set_retry_save(self, mock_communicator, mock_client, test_input, expected): mock_communicator.send_message = MagicMock() module = IqModule(mock_communicator) module.save = MagicMock() module.get = MagicMock() client_entry_name = test_input[0] value = test_input[1] if not value: module.get.return_value = 1 module.set_verify(self._CLIENT_NAME, client_entry_name, save=1) else: module.get.return_value = value module.set_verify(self._CLIENT_NAME, client_entry_name, value, save=1) assert module.save.call_args == call(self._CLIENT_NAME, client_entry_name)