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

Method test_login

tests/test_cli.py:492–543  ·  view source on GitHub ↗
(self, flow_factory)

Source from the content-addressed store, hash-verified

490
491 @mock.patch('dwave.cloud.auth.flows.LeapAuthFlow.from_config_model')
492 def test_login(self, flow_factory):
493 flow = flow_factory.return_value.__enter__.return_value
494
495 with self.subTest('dwave auth login'):
496 flow.reset_mock()
497 runner = CliRunner()
498 with runner.isolated_filesystem():
499 result = runner.invoke(cli, ['auth', 'login'])
500
501 flow.run_redirect_flow.assert_called_once()
502 self.assertEqual(result.exit_code, 0)
503
504 with self.subTest('dwave auth login --skip-valid'):
505 flow.reset_mock()
506 flow.ensure_active_token.return_value = True
507 runner = CliRunner()
508 with runner.isolated_filesystem():
509 result = runner.invoke(cli, ['auth', 'login', '--skip-valid'])
510
511 flow.ensure_active_token.assert_called_once()
512 flow.run_redirect_flow.assert_not_called()
513 self.assertEqual(result.exit_code, 0)
514
515 with self.subTest('dwave auth login --oob'):
516 flow.reset_mock()
517 runner = CliRunner()
518 with runner.isolated_filesystem():
519 result = runner.invoke(cli, ['auth', 'login', '--oob'])
520
521 flow.run_oob_flow.assert_called_once()
522 self.assertEqual(result.exit_code, 0)
523
524 with self.subTest('dwave auth login --config-file <file> --profile <profile>'):
525 config_file = 'dwave.conf'
526 profile = 'profile'
527 leap_api_endpoint = 'https://mock.dwavesys.com/leap/api'
528 config_lines = [f'[{profile}]', f'leap_api_endpoint = {leap_api_endpoint}']
529
530 flow_factory.reset_mock()
531 runner = CliRunner()
532 with runner.isolated_filesystem():
533 # create config
534 with open(config_file, 'w') as fp:
535 fp.write('\n'.join(config_lines))
536
537 result = runner.invoke(cli, ['auth', 'login',
538 '--config-file', config_file,
539 '--profile', profile])
540
541 config = validate_config_v1(dict(leap_api_endpoint=leap_api_endpoint))
542 flow_factory.assert_called_with(config)
543 self.assertEqual(result.exit_code, 0)
544
545 @mock.patch('dwave.cloud.auth.flows.LeapAuthFlow.from_config_model')
546 @ignored_warnings

Callers

nothing calls this directly

Calls 2

validate_config_v1Function · 0.90
writeMethod · 0.80

Tested by

no test coverage detected