| 428 | ("-f", ), |
| 429 | ]) |
| 430 | def test_upload(self, config_file_option): |
| 431 | config_file = 'dwave.conf' |
| 432 | profile = 'profile' |
| 433 | client_type = 'base' |
| 434 | format = 'dimodbqm' |
| 435 | problem_id = 'prob:lem:id' |
| 436 | filename = 'filename' |
| 437 | |
| 438 | with mock.patch('dwave.cloud.cli.Client') as m: |
| 439 | |
| 440 | runner = CliRunner() |
| 441 | with runner.isolated_filesystem(): |
| 442 | touch(config_file) |
| 443 | touch(filename) |
| 444 | result = runner.invoke(cli, ['upload', |
| 445 | config_file_option, config_file, |
| 446 | '--profile', profile, |
| 447 | '--client', client_type, |
| 448 | '--format', format, |
| 449 | '--problem-id', problem_id, |
| 450 | filename]) |
| 451 | |
| 452 | # proper arguments passed to Client.from_config? |
| 453 | m.from_config.assert_called_with( |
| 454 | config_file=config_file, profile=profile, |
| 455 | endpoint=None, region=None, |
| 456 | client=client_type) |
| 457 | |
| 458 | # upload method called on client? |
| 459 | c = m.from_config.return_value |
| 460 | self.assertTrue(c.upload_problem_encoded.called) |
| 461 | |
| 462 | # verify problem_id |
| 463 | args, kwargs = c.upload_problem_encoded.call_args |
| 464 | self.assertEqual(kwargs.get('problem_id'), problem_id) |
| 465 | |
| 466 | self.assertEqual(result.exit_code, 0) |
| 467 | |
| 468 | def test_platform(self): |
| 469 | runner = CliRunner() |