KDE printer manager development issue

This is a very niche problem.

I am working to create Unit Tests (autotests for end to end testing) for KDE Printer manager and there is some API issue I am facing. Whenever i try to implement the save printer function present in printermanager.cpp (void PrinterManager::savePrinter(const QString &name, const QVariantMap &saveArgs, bool isClass)) using the CUPS IP (ipp://localhost:631/ipp/print) in the saveArgs it throws error because the system is unable to connect to that server.

Now there might be 2 issues-

  1. I am not calling the function properly, i.e., the saveArgs is wrongly used.
  2. This (ipp://localhost:631/ipp/print) is not the correct url to use for testing without printer. (probably this is the issue)

Can someone help me try to understand the issue. I am linking the PR changes and detailed error log file.

Here is my changeset: Draft: Autotests: add UT for printer configiguration (!271) · Merge requests · Plasma / Print Manager · GitLab

Error log: Error.log

If it helps, I am using KDE Neon community version with latest plasma version as a virtual machine.

Things that depend on services are always tricky to test.

Sometimes it is possible to run the service as part of the test.
Sometimes it is possible to implement a small mock/fake server as part of the test.
Sometimes it is possible to abstract the server call and then fake it in the test.

However sometimes it is just not possible to do this on a unit test level and requires a more complex setup, e.g. as part of an integration test.

The problem with mocking is that we will never know if for actual server will we get same result or not.

Maybe, it is not possible to connect to CUPS server and test. But it makes me wonder that since on a linux system we do connect to cups server using localhost:631 so why can’t we connect while testing backend?

I will check if i can add this for integration test and not unit test.