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

Method test_config_ls

tests/test_cli.py:157–240  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

155
156 @ignored_warnings
157 def test_config_ls(self):
158 runner = CliRunner()
159 with runner.isolated_filesystem():
160 touch('dwave.conf')
161 with mock.patch('dwave.cloud.config.loaders.homebase.site_config_dir_list',
162 lambda **kw: ['system1', 'system2']):
163 with mock.patch('dwave.cloud.config.loaders.homebase.user_config_dir',
164 lambda **kw: 'user'):
165 with mock.patch('os.path.exists', lambda *x: True):
166 # test listing of all auto-detected config files
167 result = runner.invoke(cli, [
168 'config', 'ls'
169 ])
170 self.assertEqual(result.output.strip(), '\n'.join([
171 os.path.join('system1', 'dwave.conf'),
172 os.path.join('system2', 'dwave.conf'),
173 os.path.join('user', 'dwave.conf'),
174 os.path.join('.', 'dwave.conf')
175 ]))
176
177 # test --system
178 result = runner.invoke(cli, [
179 'config', 'ls', '--system'
180 ])
181 self.assertEqual(result.output.strip(), '\n'.join([
182 os.path.join('system1', 'dwave.conf'),
183 os.path.join('system2', 'dwave.conf')
184 ]))
185
186 # test --user
187 result = runner.invoke(cli, [
188 'config', 'ls', '--user'
189 ])
190 self.assertEqual(result.output.strip(),
191 os.path.join('user', 'dwave.conf'))
192
193 # test --local
194 result = runner.invoke(cli, [
195 'config', 'ls', '--local'
196 ])
197 self.assertEqual(result.output.strip(),
198 os.path.join('.', 'dwave.conf'))
199
200 # test --include-missing (none of the examined paths exist)
201 with mock.patch('os.path.exists', lambda *x: False):
202 # test listing of all examined paths
203 result = runner.invoke(cli, [
204 'config', 'ls', '--include-missing'
205 ])
206 self.assertEqual(result.output.strip(), '\n'.join([
207 os.path.join('system1', 'dwave.conf'),
208 os.path.join('system2', 'dwave.conf'),
209 os.path.join('user', 'dwave.conf'),
210 os.path.join('.', 'dwave.conf')
211 ]))
212
213 # test none exists
214 result = runner.invoke(cli, [

Callers

nothing calls this directly

Calls 1

touchFunction · 0.85

Tested by

no test coverage detected