def test_basic(self): sot = config.Config() self.assertEqual('/instances/%(instance_id)s/configs', sot.base_path) self.assertTrue(sot.allow_commit) self.assertTrue(sot.allow_list)
def test_update_configs(self): self.sot = _config.Config() self.proxy._get_resource = mock.Mock(return_value=self.sot) self.sot._update = mock.Mock() params = [] self.proxy.update_instance_params(instance='inst_id', params=params) self.sot._update.assert_called_with(self.proxy, params)
def test_make_it(self): sot = config.Config(instance_id=FAKE_INSTANCE_ID, **EXAMPLE) self.assertEqual(FAKE_INSTANCE_ID, sot.instance_id) self.assertEqual(EXAMPLE['param_id'], sot.id) self.assertEqual(EXAMPLE['param_name'], sot.name) self.assertEqual(EXAMPLE['param_value'], sot.value) self.assertEqual(EXAMPLE['default_value'], sot.default_value) self.assertEqual(EXAMPLE['value_type'], sot.value_type) self.assertEqual(EXAMPLE['value_range'], sot.value_range)
def test_construct_param_for_update(self): sot = config.Config(instance_id=FAKE_INSTANCE_ID) sot_dirty = { 'param_name': 'name', 'param_value': 'val', 'param_id': 'id', 'dummy': 'dummy' } sot_expected = { 'param_name': 'name', 'param_value': 'val', 'param_id': 'id', } res = sot._construct_dict_for_update(sot_dirty) self.assertDictEqual(sot_expected, res)
def test_update(self): sot = config.Config(instance_id=FAKE_INSTANCE_ID) sot2 = { 'param_name': 'name', 'param_value': 'val', 'param_id': 'id', } mock_response = mock.Mock() mock_response.status_code = 200 mock_response.json.return_value = {} mock_response.headers = {} self.sess.put.return_value = mock_response sot._update(self.sess, [sot2]) self.sess.put.assert_called_once_with('/instances/%s/configs' % FAKE_INSTANCE_ID, json={'redis_config': [sot2]})