dwavesystems / dwave-cloud-client

A minimal implementation of the REST interface used to communicate with D-Wave Solver API (SAPI) servers.
https://docs.ocean.dwavesys.com/projects/cloud-client/en/stable/
Apache License 2.0
59 stars 40 forks source link

Procedure for testing when no connection details are available #22

Open ccoffrin opened 6 years ago

ccoffrin commented 6 years ago

In a variety of cases, CI being a big one, one might not have access to a SAPI connection backend. In such cases what is the best practice for testing a code that leverages the classes provided here, Connection especially?

Would it be possible to provide a fairly well developed mock Connection for such tests? Another option would be to expose some of kind open-access backend.

randomir commented 6 years ago

Just to clarify, are you talking about testing the sampling / user program, or testing the actual Connection object?

dimod in v1.0 (stable release due soon) will provide a consistent sampling interface -- backend (local CPU sampler or remote QPU sampler) can easily be swapped (you would use dwave-micro-client-dimod as a dwave-micro-client wrapper for dimod).

Our structural-imbalance-demo and circuit-fault-diagnosis-demo are already along those lines.

ccoffrin commented 6 years ago

I am interested in writing CI tests for a user program which relies on several calls to the micro client. For example, consider how would one write tests for this code, https://github.com/lanl-ansi/dwisc?

randomir commented 6 years ago

Oh, I see. If wrapping the microclient with dimod is not an option, then a mock Connection would be a good way to go. The other option you mention, a testing/sandbox environment would also be nice to have in the future.

So, yes, we could create a Connection mock object for now to facilitate testing.