Пример #1
0
    def test_get_solver_no_defaults(self):
        """Specialized client returns the correct solver by default."""
        from dwave.cloud import qpu, sw, hybrid

        conf = dict(endpoint=config['endpoint'], token=config['token'])

        with Client(**conf) as base_client:

            with qpu.Client(**conf) as client:
                solvers = base_client.get_solvers(qpu=True)
                if solvers:
                    self.assertEqual(client.get_solver().id, solvers[0].id)
                else:
                    self.assertRaises(SolverError, client.get_solver)

            with sw.Client(**conf) as client:
                solvers = base_client.get_solvers(software=True)
                if solvers:
                    self.assertEqual(client.get_solver().id, solvers[0].id)
                else:
                    self.assertRaises(SolverError, client.get_solver)

            with hybrid.Client(**conf) as client:
                solvers = base_client.get_solvers(hybrid=True)
                if solvers:
                    self.assertEqual(client.get_solver().id, solvers[0].id)
                else:
                    self.assertRaises(SolverError, client.get_solver)
Пример #2
0
    def test_get_solver_no_defaults(self):
        from dwave.cloud import qpu, sw
        with qpu.Client(endpoint=config['endpoint'], token=config['token']) as client:
            solvers = client.get_solvers(qpu=True)
            if solvers:
                self.assertEqual(client.get_solver(), solvers[0])
            else:
                self.assertRaises(SolverError, client.get_solver)

        with sw.Client(endpoint=config['endpoint'], token=config['token']) as client:
            solvers = client.get_solvers(software=True)
            if solvers:
                self.assertEqual(client.get_solver(), solvers[0])
            else:
                self.assertRaises(SolverError, client.get_solver)