MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / test_solvers

Method test_solvers

tests/test_cli.py:390–424  ·  view source on GitHub ↗
(self, config_file_option)

Source from the content-addressed store, hash-verified

388 ("-f", ),
389 ])
390 def test_solvers(self, config_file_option):
391 config_file = 'dwave.conf'
392 profile = 'profile'
393 client_type = 'base'
394 solver = '{"qpu": true}'
395 solvers = [solver_object('A'), solver_object('B')]
396
397 with mock.patch('dwave.cloud.cli.Client') as m:
398 # mock returned solvers
399 client = m.from_config.return_value.__enter__.return_value
400 client.get_solvers.return_value = solvers
401
402 runner = CliRunner()
403 with runner.isolated_filesystem():
404 touch(config_file)
405 result = runner.invoke(cli, ['solvers',
406 config_file_option, config_file,
407 '--profile', profile,
408 '--client', client_type,
409 '--solver', solver])
410
411 # proper arguments passed to Client.from_config?
412 m.from_config.assert_called_with(
413 config_file=config_file, profile=profile,
414 endpoint=None, region=None,
415 client=client_type, solver=solver)
416
417 # get solvers called?
418 client.get_solvers.assert_called_with()
419
420 # verify exit code and stdout printout
421 self.assertEqual(result.exit_code, 0)
422 self.assertEqual(result.output.count('Solver:'), 2)
423 self.assertIn('Solver: A', result.output)
424 self.assertIn('Solver: B', result.output)
425
426 @parameterized.expand([
427 ("--config-file", ),

Callers

nothing calls this directly

Calls 2

solver_objectFunction · 0.90
touchFunction · 0.85

Tested by

no test coverage detected