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

Method test_update

tests/test_cli.py:124–151  ·  view source on GitHub ↗
(self, name, extra_opts, inputs)

Source from the content-addressed store, hash-verified

122 token="token", client="base", solver="solver")),
123 ])
124 def test_update(self, name, extra_opts, inputs):
125 config_file = 'dwave.conf'
126 profile = 'profile'
127
128 runner = CliRunner()
129 with runner.isolated_filesystem():
130 # create config
131 config_body = '\n'.join(f"{k} = old-{v}" for k,v in inputs.items())
132 with open(config_file, 'w') as fp:
133 fp.write(f"[{profile}]\n{config_body}")
134
135 # verify config before update
136 with isolated_environ(remove_dwave=True):
137 config = load_config(config_file=config_file)
138 for var, val in inputs.items():
139 self.assertEqual(config.get(var), f"old-{val}")
140
141 # update config
142 result = runner.invoke(cli, [
143 'config', 'create', '-f', config_file, '-p', profile,
144 ] + extra_opts, input='\n'.join('' if v is None else v for v in inputs.values()))
145 self.assertEqual(result.exit_code, 0)
146
147 # verify config updated
148 with isolated_environ(remove_dwave=True):
149 config = load_config(config_file=config_file)
150 for var, val in inputs.items():
151 self.assertEqual(config.get(var), val)
152
153
154class TestCli(unittest.TestCase):

Callers

nothing calls this directly

Calls 4

isolated_environClass · 0.90
load_configFunction · 0.90
writeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected