def test_from_environment_variables_is_passing_right_arguments_to_the_constructor(self, mock_cls): mock_cls.return_value = None OVC.from_environment_variables() mock_cls.assert_called_once_with({'timeout': '-1', 'ip': '10.30.4.245', 'ssl_certificate': 'certificate', 'credentials': {'username': '******', 'password': '******'}})
def test_missing_required_environment_variables_missing(self, mock_login): with self.assertRaises(exceptions.HPESimpliVityException) as error: OVC.from_environment_variables() self.assertEqual( error.exception.msg, "Make sure you have set mandatory env variables \ (SIMPLIVITYSDK_OVC_IP, SIMPLIVITYSDK_USERNAME, SIMPLIVITYSDK_PASSWORD)" )
def _create_simplivity_client(self): """ Creates Simplivity client object using module prams/env variables/config file """ if self.module.params.get('ovc_ip'): config = dict(ip=self.module.params['ovc_ip'], credentials=dict( username=self.module.params['username'], password=self.module.params['password'])) self.ovc_client = OVC(config) elif not self.module.params['config']: self.ovc_client = OVC.from_environment_variables() else: self.ovc_client = OVC.from_json_file(self.module.params['config'])
def test_from_environment_variables(self, mock_login): OVC.from_environment_variables() mock_login.assert_called_once_with('simplicity', 'root')