def test_inject_parent_settings(self, _pulp_conf, _read_config, _open): host = 'test-host' cert_path = '/path/cert' _pulp_conf.get.return_value = host _read_config.return_value.main = Mock(node_certificate=cert_path) fp = Mock() fp.__enter__ = Mock(return_value=fp) fp.__exit__ = Mock() _open.return_value = fp # test options = {} NodeProfiler._inject_parent_settings(options) # validation _pulp_conf.get.assert_called_once_with('server', 'server_name') _read_config.assert_called_once_with() _open.assert_called_once_with(cert_path) settings = options[constants.PARENT_SETTINGS] self.assertEqual(settings[constants.HOST], host) self.assertEqual(settings[constants.PORT], 443) self.assertEqual(settings[constants.NODE_CERTIFICATE], _open.return_value.read.return_value)
def test_inject_parent_settings(self, _pulp_conf, _read_config, _open): host = 'test-host' cert_path = '/path/cert' _pulp_conf.get.return_value = host _read_config.return_value.main = Mock(node_certificate=cert_path) fp = Mock() fp.__enter__ = Mock(return_value=fp) fp.__exit__ = Mock() _open.return_value = fp # test options = {} NodeProfiler._inject_parent_settings(options) # validation _pulp_conf.get.assert_called_once_with('server', 'server_name') _read_config.assert_called_once_with() _open.assert_called_once_with(cert_path) settings = options[constants.PARENT_SETTINGS] self.assertEqual(settings[constants.HOST], host) self.assertEqual(settings[constants.PORT], 443) self.assertEqual( settings[constants.NODE_CERTIFICATE], _open.return_value.read.return_value)
def test_update_units(self): consumer = Mock(id='123') units = [1, 2, 3] options = {} config = Mock() conduit = Mock() # test profiler = NodeProfiler() profiler._inject_parent_settings = Mock() profiler._inject_strategy = Mock() # validation _units = profiler.update_units(consumer, units, options, config, conduit) profiler._inject_parent_settings.assert_called_once_with(options) profiler._inject_strategy.assert_called_once_with(consumer.id, options) self.assertEqual(_units, units)