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

Method test_init

tests/api/test_api_clients.py:68–95  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

66 self.assertEqual(retry.total, conf['total'])
67
68 def test_init(self):
69 config = dict(endpoint='https://test.com/path/',
70 token=str(uuid.uuid4()),
71 timeout=1,
72 retry=dict(total=3),
73 headers={'Custom': 'Field 123'},
74 verify=False,
75 proxies={'https': 'http://proxy.com'},
76 cache=dict(enabled=True, store_factory=lambda **kw: MemoryCache()))
77
78 with DWaveAPIClient(**config) as client:
79 session = client.session
80 self.assertIsInstance(session, requests.Session)
81
82 self.assertEqual(session.base_url, config['endpoint'])
83 self.assertEqual(session.cert, None)
84 self.assertEqual(session.headers['X-Auth-Token'], config['token'])
85 self.assertEqual(session.headers['Custom'], config['headers']['Custom'])
86 self.assertIn(__packagename__, session.headers['User-Agent'])
87 self.assertIn(__version__, session.headers['User-Agent'])
88 self.assertEqual(session.verify, config['verify'])
89 self.assertEqual(session.proxies, config['proxies'])
90 self.assertEqual(session._cache_enabled, True)
91 self.assertEqual(session._store, {})
92
93 # verify Retry object config
94 retry = session.get_adapter('https://').max_retries
95 self.assertEqual(retry.total, config['retry']['total'])
96
97 def test_cache_disable(self):
98 config = validate_config_v1(dict(cache_home='off', endpoint='mock'))

Callers

nothing calls this directly

Calls 2

MemoryCacheClass · 0.90
DWaveAPIClientClass · 0.90

Tested by

no test coverage detected