def setUp(self): super(TestEAPIClientExecute, self).setUp() mock.patch('requests.Session.post').start() self.mock_log = mock.patch.object(api, 'LOG').start() self.mock_json_dumps = mock.patch.object(api.json, 'dumps').start() self.addCleanup(mock.patch.stopall) self.client = api.EAPIClient('10.0.0.1', timeout=99)
def test_basic_init(self): host_ip = '10.20.30.40' client = api.EAPIClient(host_ip) self.assertEqual(client.host, host_ip) self.assertEqual(client.url, 'https://10.20.30.40/command-api') self.assertDictContainsSubset( { 'Content-Type': 'application/json', 'Accept': 'application/json' }, client.session.headers)
def test_init_timeout(self): client = api.EAPIClient('10.0.0.1', timeout=99) self.assertEqual(client.timeout, 99)
def test_init_auth(self): client = api.EAPIClient('10.0.0.1', username='******', password='******') self.assertEqual(client.session.auth, ('user', 'pass'))
def test_init_enable_verify(self): client = api.EAPIClient('10.0.0.1', verify=True) self.assertTrue(client.session.verify)
def _make_eapi_client(self, host): return api.EAPIClient(host, username=self._hosts[host]['user'], password=self._hosts[host]['password'], verify=False, timeout=cfg.CONF.ml2_arista.conn_timeout)